File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
modules/module-postgres-storage/src/migrations/scripts Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments