Fix Conf.db in migrations
This commit is contained in:
parent
04018015c5
commit
4330cae626
|
@ -3,7 +3,7 @@ import { Kysely, sql } from 'kysely';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
|
|
||||||
export async function up(db: Kysely<any>): Promise<void> {
|
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);
|
await sql`CREATE VIRTUAL TABLE events_fts USING fts5(id, content)`.execute(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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('tags').renameTo('nostr_tags').execute();
|
||||||
await db.schema.alterTable('nostr_tags').renameColumn('tag', 'name').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 db.schema.dropTable('events_fts').execute();
|
||||||
await sql`CREATE VIRTUAL TABLE nostr_fts5 USING fts5(event_id, content)`.execute(db);
|
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('nostr_tags').renameTo('tags').execute();
|
||||||
await db.schema.alterTable('tags').renameColumn('name', 'tag').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 db.schema.dropTable('nostr_fts5').execute();
|
||||||
await sql`CREATE VIRTUAL TABLE events_fts USING fts5(id, content)`.execute(db);
|
await sql`CREATE VIRTUAL TABLE events_fts USING fts5(id, content)`.execute(db);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Kysely, sql } from 'kysely';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
|
|
||||||
export async function up(db: Kysely<any>): Promise<void> {
|
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')
|
await db.schema.createTable('nostr_pgfts')
|
||||||
.ifNotExists()
|
.ifNotExists()
|
||||||
.addColumn('event_id', 'text', (c) => c.primaryKey().references('nostr_events.id').onDelete('cascade'))
|
.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> {
|
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();
|
await db.schema.dropTable('nostr_pgfts').ifExists().execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Kysely } from 'kysely';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
|
|
||||||
export async function up(db: Kysely<any>): Promise<void> {
|
export async function up(db: Kysely<any>): Promise<void> {
|
||||||
if (['postgres:', 'postgresql:'].includes(Conf.databaseUrl.protocol!)) {
|
if (Conf.db.dialect === 'postgres') {
|
||||||
await db.schema
|
await db.schema
|
||||||
.createIndex('nostr_pgfts_gin_search_vec')
|
.createIndex('nostr_pgfts_gin_search_vec')
|
||||||
.ifNotExists()
|
.ifNotExists()
|
||||||
|
@ -15,7 +15,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(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();
|
await db.schema.dropIndex('nostr_pgfts_gin_search_vec').ifExists().execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue