mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-31 02:54:21 +01:00
Merge branch 'main' into 'use-postgres-js'
# Conflicts: # deno.json # src/db/adapters/DittoPostgres.ts
This commit is contained in:
@@ -7,6 +7,7 @@ export interface DittoTables {
|
||||
author_stats: AuthorStatsRow;
|
||||
event_stats: EventStatsRow;
|
||||
pubkey_domains: PubkeyDomainRow;
|
||||
event_zaps: EventZapRow;
|
||||
}
|
||||
|
||||
interface AuthorStatsRow {
|
||||
@@ -69,3 +70,11 @@ interface PubkeyDomainRow {
|
||||
domain: string;
|
||||
last_updated_at: number;
|
||||
}
|
||||
|
||||
interface EventZapRow {
|
||||
receipt_id: string;
|
||||
target_event_id: string;
|
||||
sender_pubkey: string;
|
||||
amount_millisats: number;
|
||||
comment: string;
|
||||
}
|
||||
|
||||
32
src/db/migrations/027_add_zap_events.ts
Normal file
32
src/db/migrations/027_add_zap_events.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Kysely } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('event_zaps')
|
||||
.addColumn('receipt_id', 'text', (col) => col.primaryKey())
|
||||
.addColumn('target_event_id', 'text', (col) => col.notNull())
|
||||
.addColumn('sender_pubkey', 'text', (col) => col.notNull())
|
||||
.addColumn('amount_millisats', 'integer', (col) => col.notNull())
|
||||
.addColumn('comment', 'text', (col) => col.notNull())
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex('idx_event_zaps_amount_millisats')
|
||||
.on('event_zaps')
|
||||
.column('amount_millisats')
|
||||
.ifNotExists()
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex('idx_event_zaps_target_event_id')
|
||||
.on('event_zaps')
|
||||
.column('target_event_id')
|
||||
.ifNotExists()
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropIndex('idx_event_zaps_amount_millisats').ifExists().execute();
|
||||
await db.schema.dropIndex('idx_event_zaps_target_event_id').ifExists().execute();
|
||||
await db.schema.dropTable('event_zaps').execute();
|
||||
}
|
||||
Reference in New Issue
Block a user