Add connections table

This commit is contained in:
Alex Gleason 2024-05-26 19:21:15 -05:00
parent 11474c5cbd
commit 0141a732c3
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 27 additions and 0 deletions

View File

@ -2,6 +2,7 @@ export interface DittoTables {
nostr_events: EventRow;
nostr_tags: TagRow;
nostr_fts5: EventFTSRow;
connections: ConnectionRow;
unattached_media: UnattachedMediaRow;
author_stats: AuthorStatsRow;
event_stats: EventStatsRow;
@ -44,6 +45,15 @@ interface TagRow {
value: string;
}
interface ConnectionRow {
api_token: string;
user_pubkey: string;
server_seckey: Uint8Array;
server_pubkey: string;
relays: string;
connected_at: Date;
}
interface UnattachedMediaRow {
id: string;
pubkey: string;

View File

@ -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();
}