mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
stats: add migration for stats tables
This commit is contained in:
parent
0f10a7c3a2
commit
8b03d492a1
1 changed files with 24 additions and 0 deletions
24
src/db/migrations/009_add_stats.ts
Normal file
24
src/db/migrations/009_add_stats.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { Kysely } from '@/deps.ts';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('pubkey_stats')
|
||||
.addColumn('pubkey', 'text', (col) => col.primaryKey())
|
||||
.addColumn('followers_count', 'integer', (col) => col.notNull().defaultTo(0))
|
||||
.addColumn('following_count', 'integer', (col) => col.notNull().defaultTo(0))
|
||||
.addColumn('notes_count', 'integer', (col) => col.notNull().defaultTo(0))
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createTable('event_stats')
|
||||
.addColumn('event_id', 'text', (col) => col.primaryKey().references('events.id').onDelete('cascade'))
|
||||
.addColumn('replies_count', 'integer', (col) => col.notNull().defaultTo(0))
|
||||
.addColumn('reposts_count', 'integer', (col) => col.notNull().defaultTo(0))
|
||||
.addColumn('reactions_count', 'integer', (col) => col.notNull().defaultTo(0))
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable('pubkey_stats').execute();
|
||||
await db.schema.dropTable('event_stats').execute();
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue