Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Alternative for transpiling (#522) * Support for TS migrations * Typing for shorthands * Fixed lint * Checks in custom migration
- Loading branch information
Showing
12 changed files
with
171 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { resolve } from 'path' | ||
import runner, { RunnerOption } from '../../dist' | ||
|
||
const run = async () => { | ||
try { | ||
const options: Omit<RunnerOption, 'direction'> & { databaseUrl: string } = { | ||
migrationsTable: 'migrations', | ||
dir: resolve(__dirname, 'migrations'), | ||
count: Infinity, | ||
databaseUrl: process.env.DATABASE_URL, | ||
} | ||
const upResult = await runner({ | ||
...options, | ||
direction: 'up', | ||
}) | ||
if (upResult.length !== 1) { | ||
console.error('There should be exactly one migration processed') | ||
process.exit(1) | ||
} | ||
console.log('Up success') | ||
console.log(upResult) | ||
const downResult = await runner({ | ||
...options, | ||
direction: 'down', | ||
}) | ||
if (downResult.length !== 1) { | ||
console.error('There should be exactly one migration processed') | ||
process.exit(1) | ||
} | ||
console.log('Down success') | ||
console.log(downResult) | ||
process.exit(0) | ||
} catch (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { MigrationBuilder, ColumnDefinitions } from '../../../dist' | ||
|
||
export const shorthands: ColumnDefinitions = undefined | ||
|
||
export async function up(pgm: MigrationBuilder): Promise<void> { | ||
pgm.createTable('t1', { | ||
id: 'id', | ||
string: { type: 'text', notNull: true }, | ||
created: { | ||
type: 'timestamp', | ||
notNull: true, | ||
default: pgm.func('current_timestamp'), | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters