c2d0578b5a
* init bsky-sync * add bsync models and config * rename bsky-sync to bsync * protos and gen for bsync service * start roughing-out bsync routes * adjust bsync model, validation * bsync auth, context, notify * implement bsync scan mute ops, listen for mute op event * setup basic bsync tests, misc fixes * rename some files * reorg bsync server routes * reorg bsync server routes * tests * test input validation to addMuteOperation * add db stats to bsync * add bsync service * redact bsync auth header from logs * upgrade typescript to v5.3 * prettier on codegened bsync files
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
#!/usr/bin/env ts-node
|
|
|
|
import * as fs from 'fs/promises'
|
|
import * as path from 'path'
|
|
|
|
export async function main() {
|
|
const now = new Date()
|
|
const prefix = now.toISOString().replace(/[^a-z0-9]/gi, '') // Order of migrations matches alphabetical order of their names
|
|
const name = process.argv[2]
|
|
if (!name || !name.match(/^[a-z0-9-]+$/)) {
|
|
process.exitCode = 1
|
|
return console.error(
|
|
'Must pass a migration name consisting of lowercase digits, numbers, and dashes.',
|
|
)
|
|
}
|
|
const filename = `${prefix}-${name}`
|
|
const dir = path.join(__dirname, '..', 'src', 'db', 'migrations')
|
|
|
|
await fs.writeFile(path.join(dir, `${filename}.ts`), template, { flag: 'wx' })
|
|
await fs.writeFile(
|
|
path.join(dir, 'index.ts'),
|
|
`export * as _${prefix} from './${filename}'\n`,
|
|
{ flag: 'a' },
|
|
)
|
|
}
|
|
|
|
const template = `import { Kysely } from 'kysely'
|
|
|
|
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
// Migration code
|
|
}
|
|
|
|
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
// Migration code
|
|
}
|
|
`
|
|
|
|
main()
|