Skip to content

Commit

Permalink
chore: add replica setting (#14)
Browse files Browse the repository at this point in the history
* chore: add replica setting

* chore: update down sql
  • Loading branch information
appflowy authored Aug 21, 2023
1 parent fd477e9 commit e9eea26
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions postgres/migrations/V5__replica.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'af_workspace_member_pkey')
THEN
ALTER TABLE af_workspace_member DROP CONSTRAINT af_workspace_member_pkey;
END IF;
END $$;
1 change: 1 addition & 0 deletions postgres/migrations/V5__replica.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE af_workspace_member ADD PRIMARY KEY (uid, workspace_id);
3 changes: 3 additions & 0 deletions postgres/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ pub async fn run_down_migration(client: &Client) -> Result<(), Error> {
let sql = include_str!("../migrations/V4__encryption.down.sql");
client.batch_execute(sql).await?;

let sql = include_str!("../migrations/V5__replica.down.sql");
client.batch_execute(sql).await?;

client
.batch_execute("DROP TABLE IF EXISTS af_migration_history")
.await?;
Expand Down

0 comments on commit e9eea26

Please sign in to comment.