Closed hannesj closed 1 year ago
Did this make it into a release as this doesn't seem to be working for me. I'm still getting a typescript error on the argument I'm passing to alterColumn
.
export const ModerationReasons = [
'SPAM',
'INACTIVE',
'CUSTOM'
] as const;
export const up = async (db: Kysely<unknown>) => {
// Moderation
await db.schema
.alterTable('moderation')
.alterColumn('reason', col => col.setDataType(sql`enum(${sql.join(Object.values(ModerationReasons).map(arg => sql.lit(arg)))})`))
.execute();
};
This works but the above doesn't.
export const up = async (db: Kysely<unknown>) => {
// Moderation
await db.schema
.createTable('moderation')
.ifNotExists()
.addColumn('id', 'varchar(36)', (col) => col.defaultTo(sql`(uuid())`).primaryKey().notNull())
.addColumn('reason', sql`enum(${sql.join(Object.values(ModerationReasons).map(arg => sql.lit(arg)))})`, col => col.notNull())
.execute();
};
@hannesj @ImLunaHey this has been released.
This is a small issue with the ts typings.
The following works:
But the following is not allowed:
The second argument of
addColumn
is aDataTypeExpression
which isColumnDataType | Expression<any>
, while the argument forsetDataType
is justColumnDataType