Skip to content

Commit 8f33247

Browse files
committed
Add missing migration.
1 parent df8b2dc commit 8f33247

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { migrations } from '@powersync/service-core';
2+
import { openMigrationDB } from '../migration-utils.js';
3+
4+
export const up: migrations.PowerSyncMigrationFunction = async (context) => {
5+
const {
6+
service_context: { configuration }
7+
} = context;
8+
await using client = openMigrationDB(configuration.storage);
9+
await client.transaction(async (db) => {
10+
await db.sql`
11+
ALTER TABLE current_data
12+
ADD COLUMN pending_delete BIGINT NULL
13+
`.execute();
14+
await db.sql`
15+
CREATE INDEX IF NOT EXISTS current_data_pending_deletes ON current_data (group_id, pending_delete)
16+
WHERE
17+
pending_delete IS NOT NULL
18+
`.execute();
19+
});
20+
};
21+
22+
export const down: migrations.PowerSyncMigrationFunction = async (context) => {
23+
const {
24+
service_context: { configuration }
25+
} = context;
26+
await using client = openMigrationDB(configuration.storage);
27+
await client.transaction(async (db) => {
28+
await db.sql`DROP INDEX IF EXISTS current_data_pending_deletes`.execute();
29+
await db.sql`
30+
ALTER TABLE current_data
31+
DROP COLUMN pending_delete
32+
`.execute();
33+
});
34+
};

0 commit comments

Comments
 (0)