Fix Conf.db in migrations

This commit is contained in:
Alex Gleason 2024-05-24 20:16:51 -05:00
parent 04018015c5
commit 4330cae626
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,7 @@ import { Kysely, sql } from 'kysely';
import { Conf } from '@/config.ts';
export async function up(db: Kysely<any>): Promise<void> {
if (Conf.databaseUrl.protocol === 'sqlite:') {
if (Conf.db.dialect === 'sqlite') {
await sql`CREATE VIRTUAL TABLE events_fts USING fts5(id, content)`.execute(db);
}
}

View File

@ -7,7 +7,7 @@ export async function up(db: Kysely<any>): Promise<void> {
await db.schema.alterTable('tags').renameTo('nostr_tags').execute();
await db.schema.alterTable('nostr_tags').renameColumn('tag', 'name').execute();
if (Conf.databaseUrl.protocol === 'sqlite:') {
if (Conf.db.dialect === 'sqlite') {
await db.schema.dropTable('events_fts').execute();
await sql`CREATE VIRTUAL TABLE nostr_fts5 USING fts5(event_id, content)`.execute(db);
}
@ -18,7 +18,7 @@ export async function down(db: Kysely<any>): Promise<void> {
await db.schema.alterTable('nostr_tags').renameTo('tags').execute();
await db.schema.alterTable('tags').renameColumn('name', 'tag').execute();
if (Conf.databaseUrl.protocol === 'sqlite:') {
if (Conf.db.dialect === 'sqlite') {
await db.schema.dropTable('nostr_fts5').execute();
await sql`CREATE VIRTUAL TABLE events_fts USING fts5(id, content)`.execute(db);
}

View File

@ -3,7 +3,7 @@ import { Kysely, sql } from 'kysely';
import { Conf } from '@/config.ts';
export async function up(db: Kysely<any>): Promise<void> {
if (['postgres:', 'postgresql:'].includes(Conf.databaseUrl.protocol!)) {
if (Conf.db.dialect === 'postgres') {
await db.schema.createTable('nostr_pgfts')
.ifNotExists()
.addColumn('event_id', 'text', (c) => c.primaryKey().references('nostr_events.id').onDelete('cascade'))
@ -13,7 +13,7 @@ export async function up(db: Kysely<any>): Promise<void> {
}
export async function down(db: Kysely<any>): Promise<void> {
if (['postgres:', 'postgresql:'].includes(Conf.databaseUrl.protocol!)) {
if (Conf.db.dialect === 'postgres') {
await db.schema.dropTable('nostr_pgfts').ifExists().execute();
}
}

View File

@ -3,7 +3,7 @@ import { Kysely } from 'kysely';
import { Conf } from '@/config.ts';
export async function up(db: Kysely<any>): Promise<void> {
if (['postgres:', 'postgresql:'].includes(Conf.databaseUrl.protocol!)) {
if (Conf.db.dialect === 'postgres') {
await db.schema
.createIndex('nostr_pgfts_gin_search_vec')
.ifNotExists()
@ -15,7 +15,7 @@ export async function up(db: Kysely<any>): Promise<void> {
}
export async function down(db: Kysely<any>): Promise<void> {
if (['postgres:', 'postgresql:'].includes(Conf.databaseUrl.protocol!)) {
if (Conf.db.dialect === 'postgres') {
await db.schema.dropIndex('nostr_pgfts_gin_search_vec').ifExists().execute();
}
}