mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Rename nostr_events_new_pkey to nostr_events_pkey
This commit is contained in:
parent
497d5d12c9
commit
02d4235abd
2 changed files with 24 additions and 0 deletions
12
packages/db/migrations/052_rename_pkey.ts
Normal file
12
packages/db/migrations/052_rename_pkey.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { type Kysely, sql } from 'kysely';
|
||||||
|
|
||||||
|
export async function up(db: Kysely<unknown>): Promise<void> {
|
||||||
|
try {
|
||||||
|
await sql`ALTER INDEX nostr_events_new_pkey RENAME TO nostr_events_pkey;`.execute(db);
|
||||||
|
} catch {
|
||||||
|
// all good
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(_db: Kysely<unknown>): Promise<void> {
|
||||||
|
}
|
||||||
|
|
@ -210,6 +210,16 @@ Deno.test('throws a RelayError when inserting an event deleted by a user', async
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test('inserting the same event twice', async () => {
|
||||||
|
await using db = await createTestDB({ pure: true });
|
||||||
|
const { store } = db;
|
||||||
|
|
||||||
|
const event = genEvent({ kind: 1 });
|
||||||
|
|
||||||
|
await store.event(event);
|
||||||
|
await store.event(event);
|
||||||
|
});
|
||||||
|
|
||||||
Deno.test('inserting replaceable events', async () => {
|
Deno.test('inserting replaceable events', async () => {
|
||||||
await using db = await createTestDB({ pure: true });
|
await using db = await createTestDB({ pure: true });
|
||||||
const { store } = db;
|
const { store } = db;
|
||||||
|
|
@ -225,6 +235,8 @@ Deno.test('inserting replaceable events', async () => {
|
||||||
const newerEvent = genEvent({ kind: 0, created_at: 999 }, sk);
|
const newerEvent = genEvent({ kind: 0, created_at: 999 }, sk);
|
||||||
await store.event(newerEvent);
|
await store.event(newerEvent);
|
||||||
assertEquals(await store.query([{ kinds: [0] }]), [newerEvent]);
|
assertEquals(await store.query([{ kinds: [0] }]), [newerEvent]);
|
||||||
|
|
||||||
|
await store.event(olderEvent); // doesn't throw
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test("throws a RelayError when querying an event with a large 'since'", async () => {
|
Deno.test("throws a RelayError when querying an event with a large 'since'", async () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue