Add connections table
This commit is contained in:
parent
11474c5cbd
commit
0141a732c3
|
@ -2,6 +2,7 @@ export interface DittoTables {
|
||||||
nostr_events: EventRow;
|
nostr_events: EventRow;
|
||||||
nostr_tags: TagRow;
|
nostr_tags: TagRow;
|
||||||
nostr_fts5: EventFTSRow;
|
nostr_fts5: EventFTSRow;
|
||||||
|
connections: ConnectionRow;
|
||||||
unattached_media: UnattachedMediaRow;
|
unattached_media: UnattachedMediaRow;
|
||||||
author_stats: AuthorStatsRow;
|
author_stats: AuthorStatsRow;
|
||||||
event_stats: EventStatsRow;
|
event_stats: EventStatsRow;
|
||||||
|
@ -44,6 +45,15 @@ interface TagRow {
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ConnectionRow {
|
||||||
|
api_token: string;
|
||||||
|
user_pubkey: string;
|
||||||
|
server_seckey: Uint8Array;
|
||||||
|
server_pubkey: string;
|
||||||
|
relays: string;
|
||||||
|
connected_at: Date;
|
||||||
|
}
|
||||||
|
|
||||||
interface UnattachedMediaRow {
|
interface UnattachedMediaRow {
|
||||||
id: string;
|
id: string;
|
||||||
pubkey: string;
|
pubkey: string;
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Kysely, sql } from 'kysely';
|
||||||
|
|
||||||
|
export async function up(db: Kysely<any>): Promise<void> {
|
||||||
|
await db.schema
|
||||||
|
.createTable('connections')
|
||||||
|
.addColumn('api_token', 'text', (col) => col.primaryKey().unique().notNull())
|
||||||
|
.addColumn('user_pubkey', 'text', (col) => col.notNull())
|
||||||
|
.addColumn('server_seckey', 'blob', (col) => col.notNull())
|
||||||
|
.addColumn('server_pubkey', 'text', (col) => col.notNull())
|
||||||
|
.addColumn('relays', 'text', (col) => col.defaultTo('[]'))
|
||||||
|
.addColumn('connected_at', 'timestamp', (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(db: Kysely<any>): Promise<void> {
|
||||||
|
await db.schema.dropTable('connections').execute();
|
||||||
|
}
|
Loading…
Reference in New Issue