mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-13 18:44:22 +01:00
feat: add migration for event_zaps;create idx_event_zaps_id_amount
This commit is contained in:
26
src/db/migrations/027_add_zap_events.ts
Normal file
26
src/db/migrations/027_add_zap_events.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Kysely } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('event_zaps')
|
||||
.ifNotExists()
|
||||
.addColumn('receipt_id', 'text', (col) => col.primaryKey())
|
||||
.addColumn('target_event_id', 'text', (col) => col.notNull())
|
||||
.addColumn('sender_pubkey', 'text', (col) => col.notNull())
|
||||
.addColumn('amount', 'integer', (col) => col.notNull())
|
||||
.addColumn('comment', 'text', (col) => col.notNull())
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex('idx_event_zaps_id_amount')
|
||||
.on('event_zaps')
|
||||
.column('amount')
|
||||
.column('target_event_id')
|
||||
.ifNotExists()
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropIndex('idx_event_zaps_id_amount').execute();
|
||||
await db.schema.dropTable('event_zaps').execute();
|
||||
}
|
||||
Reference in New Issue
Block a user