Skip to content

Commit e667345

Browse files
committed
feat: support alter table replica identity in pg
1 parent 727e515 commit e667345

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pegjs/postgresql.pegjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,7 @@ alter_action
19011901
/ ALTER_COLUMN_DATA_TYPE
19021902
/ ALTER_COLUMN_DEFAULT
19031903
/ ALTER_COLUMN_NOT_NULL
1904+
/ ALTER_REPLICA_IDENTITY
19041905

19051906
ALTER_ADD_COLUMN
19061907
= KW_ADD __
@@ -2162,6 +2163,25 @@ ALTER_COLUMN_NOT_NULL
21622163
type: 'alter',
21632164
}
21642165
}
2166+
2167+
ALTER_REPLICA_IDENTITY
2168+
= 'REPLICA'i __ 'IDENTITY'i __ n:('DEFAULT'i / 'FULL'i / 'NOTHING'i) {
2169+
/* => {
2170+
action: 'replica';
2171+
keyword?: 'identity';
2172+
resource: 'replica_identity';
2173+
type: 'alter';
2174+
replica_identity: 'default' | 'full' | 'nothing';
2175+
}
2176+
*/
2177+
return {
2178+
action: 'replica',
2179+
keyword: 'identity',
2180+
resource: 'replica_identity',
2181+
replica_identity: n,
2182+
type: 'alter',
2183+
}
2184+
}
21652185
create_index_definition
21662186
= kc:(KW_INDEX / KW_KEY) __
21672187
c:column? __

test/postgres.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,13 @@ describe('Postgres', () => {
19431943
'ALTER TABLE "configuration" ADD CONSTRAINT "configuration_pk" PRIMARY KEY ("something", "something_else", "something_something_else")',
19441944
]
19451945
},
1946+
{
1947+
title: 'alter replica identity',
1948+
sql: [
1949+
'ALTER TABLE "table_name" REPLICA IDENTITY FULL;',
1950+
'ALTER TABLE "table_name" REPLICA IDENTITY FULL',
1951+
]
1952+
},
19461953
]
19471954
function neatlyNestTestedSQL(sqlList){
19481955
sqlList.forEach(sqlInfo => {

0 commit comments

Comments
 (0)