diff --git a/src/db/migrations/036_stats64.ts b/src/db/migrations/036_stats64.ts new file mode 100644 index 00000000..fa9d357e --- /dev/null +++ b/src/db/migrations/036_stats64.ts @@ -0,0 +1,14 @@ +import { Kysely, sql } from 'kysely'; + +export async function up(db: Kysely): Promise { + await db.deleteFrom('event_stats').where(sql`length(event_id)`, '>', 64).execute(); + await db.deleteFrom('author_stats').where(sql`length(pubkey)`, '>', 64).execute(); + + await db.schema.alterTable('event_stats').alterColumn('event_id', (col) => col.setDataType('char(64)')).execute(); + await db.schema.alterTable('author_stats').alterColumn('pubkey', (col) => col.setDataType('char(64)')).execute(); +} + +export async function down(db: Kysely): Promise { + await db.schema.alterTable('event_stats').alterColumn('event_id', (col) => col.setDataType('text')).execute(); + await db.schema.alterTable('author_stats').alterColumn('pubkey', (col) => col.setDataType('text')).execute(); +}