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 { interface RelayRow {
url: string; url: string;
domain: string;
active: boolean;
} }
const db = new Kysely<DittoDB>({ const db = new Kysely<DittoDB>({

View File

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

View File

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