db/relays: add `active` column

This commit is contained in:
Alex Gleason 2023-08-15 19:07:26 -05:00
parent 92f5bea891
commit a0769d7c92
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 5 additions and 1 deletions

View File

@ -37,6 +37,8 @@ interface UserRow {
interface RelayRow {
url: string;
domain: string;
active: boolean;
}
const db = new Kysely<DittoDB>({

View File

@ -5,6 +5,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.createTable('relays')
.addColumn('url', 'text', (col) => col.primaryKey())
.addColumn('domain', 'text', (col) => col.notNull())
.addColumn('active', 'boolean', (col) => col.notNull())
.execute();
}

View File

@ -7,7 +7,8 @@ function addRelays(relays: `wss://${string}`[]) {
const values = relays.map((url) => ({
url,
domain: tldts.getDomain(url),
domain: tldts.getDomain(url)!,
active: true,
}));
return db.insertInto('relays')