mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
stats64: delete invalid rows first
This commit is contained in:
parent
2b2cdca282
commit
f0c8096498
1 changed files with 6 additions and 3 deletions
|
|
@ -1,11 +1,14 @@
|
|||
import { Kysely } from 'kysely';
|
||||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.alterTable('author_stats').alterColumn('pubkey', (col) => col.setDataType('char(64)')).execute();
|
||||
await db.deleteFrom('event_stats').where(sql<number>`length(event_id)`, '>', 64).execute();
|
||||
await db.deleteFrom('author_stats').where(sql<number>`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<any>): Promise<void> {
|
||||
await db.schema.alterTable('author_stats').alterColumn('pubkey', (col) => col.setDataType('text')).execute();
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue