Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed May 3, 2024
1 parent 3a92588 commit 3c6867b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/admin/src/server/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const migrationsRotuer = trpc.router({
const {content, info} = await migrator.generateDownMigration({name: input.name})

const downPath = migrator.downPath(info.migration.path as string)
await fs.promises.mkdir(path.dirname(downPath), {recursive: true})
await fs.promises.writeFile(downPath, content)
return {downPath, content}
}),
Expand Down
3 changes: 2 additions & 1 deletion packages/migrator/src/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ export class Migrator extends umzug.Umzug<MigratorContext> {
pgpOptions: this.client.pgpOptions,
})

const migrator = new Migrator({...this.migratorOptions, client})
const MigratorClass = this.constructor as typeof Migrator // todo: how do we know we can pass the same kind of constructor parameters to this
const migrator = new MigratorClass({...this.migratorOptions, client})

const create = () => this.client.query(sql`create database ${sql.identifier([dbName])}`)

Expand Down
14 changes: 7 additions & 7 deletions packages/schemainspect/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ export const unquoted_identifier = (identifier: string, schema?: string, identit
return s
}

export const canSkipQuotes = (identifier: string) => /^[_a-z]+$/.test(identifier)

export const quoted_identifier = (identifier: string, schema?: string, identity_arguments?: string) => {
// let s = [identifier, schema]
// .filter(Boolean)
// .map(s => (/^[\d_a-z]+$/.test(s) ? s : `"${s.replaceAll(`"`, `""`)}"`))
// .join('.')
// if (canSkipQuotes(identifier) && !schema && !identity_arguments) {
// return identifier // no need for quotes
// }

// if (identity_arguments) {
// s += `(${identity_arguments})`
// if (canSkipQuotes(identifier) && canSkipQuotes(schema) && !identity_arguments) {
// return `${schema}.${identifier}` // no need for quotes
// }

// return s
if (!identifier && schema) {
return `"${schema.replaceAll(`"`, '""')}"`
}
Expand Down

0 comments on commit 3c6867b

Please sign in to comment.