Merge branch 'sqlite3' into 'main'
Switch main database to Deno SQLite3 See merge request soapbox-pub/ditto!54
This commit is contained in:
commit
fe99e4a053
10
deno.json
10
deno.json
|
@ -2,12 +2,12 @@
|
|||
"$schema": "https://deno.land/x/deno@v1.32.3/cli/schemas/config-file.v1.json",
|
||||
"lock": false,
|
||||
"tasks": {
|
||||
"start": "deno run --allow-read --allow-write=data --allow-env --allow-net --allow-sys src/server.ts",
|
||||
"dev": "deno run --allow-read --allow-write=data --allow-env --allow-net --allow-sys --watch src/server.ts",
|
||||
"debug": "deno run --allow-read --allow-write=data --allow-env --allow-net --allow-sys --inspect src/server.ts",
|
||||
"test": "DB_PATH=\":memory:\" deno test --allow-read --allow-write=data --allow-env src",
|
||||
"start": "deno run -A --unstable src/server.ts",
|
||||
"dev": "deno run -A --unstable --watch src/server.ts",
|
||||
"debug": "deno run -A --unstable --inspect src/server.ts",
|
||||
"test": "DB_PATH=\":memory:\" deno test -A --unstable src",
|
||||
"check": "deno check src/server.ts",
|
||||
"relays:sync": "deno run -A scripts/relays.ts sync"
|
||||
"relays:sync": "deno run -A --unstable scripts/relays.ts sync"
|
||||
},
|
||||
"imports": {
|
||||
"@/": "./src/",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import { DenoSqliteDialect, FileMigrationProvider, Kysely, Migrator, Sqlite } from '@/deps.ts';
|
||||
import { DenoSqlite3, DenoSqliteDialect, FileMigrationProvider, Kysely, Migrator } from '@/deps.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
|
||||
interface DittoDB {
|
||||
|
@ -57,7 +57,7 @@ interface UnattachedMediaRow {
|
|||
|
||||
const db = new Kysely<DittoDB>({
|
||||
dialect: new DenoSqliteDialect({
|
||||
database: new Sqlite(Conf.dbPath),
|
||||
database: new DenoSqlite3(Conf.dbPath),
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { db } from '@/db.ts';
|
||||
import { type Event, SqliteError } from '@/deps.ts';
|
||||
import { type Event } from '@/deps.ts';
|
||||
import { isParameterizedReplaceableKind } from '@/kinds.ts';
|
||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||
import { EventData } from '@/types.ts';
|
||||
|
@ -64,7 +64,7 @@ function insertEvent(event: Event, data: EventData): Promise<void> {
|
|||
]);
|
||||
}).catch((error) => {
|
||||
// Don't throw for duplicate events.
|
||||
if (error instanceof SqliteError && error.code === 19) {
|
||||
if (error.message.includes('UNIQUE constraint failed')) {
|
||||
return;
|
||||
} else {
|
||||
throw error;
|
||||
|
|
|
@ -56,6 +56,7 @@ export {
|
|||
DB as Sqlite,
|
||||
SqliteError,
|
||||
} from 'https://raw.githubusercontent.com/alexgleason/deno-sqlite/325f66d8c395e7f6f5ee78ebfa42a0eeea4a942b/mod.ts';
|
||||
export { Database as DenoSqlite3 } from 'https://deno.land/x/sqlite3@0.9.1/mod.ts';
|
||||
export * as dotenv from 'https://deno.land/std@0.198.0/dotenv/mod.ts';
|
||||
export {
|
||||
FileMigrationProvider,
|
||||
|
@ -65,7 +66,7 @@ export {
|
|||
type NullableInsertKeys,
|
||||
sql,
|
||||
} from 'npm:kysely@^0.25.0';
|
||||
export { DenoSqliteDialect } from 'https://gitlab.com/soapbox-pub/kysely-deno-sqlite/-/raw/v1.0.1/mod.ts';
|
||||
export { DenoSqliteDialect } from 'https://gitlab.com/soapbox-pub/kysely-deno-sqlite/-/raw/v1.1.0/mod.ts';
|
||||
export { default as tldts } from 'npm:tldts@^6.0.14';
|
||||
export * as cron from 'https://deno.land/x/deno_cron@v1.0.0/cron.ts';
|
||||
export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts';
|
||||
|
|
Loading…
Reference in New Issue