Skip to content

Commit

Permalink
fix(#193): only create indexes if table does not exist (#194)
Browse files Browse the repository at this point in the history
* fix(#193): add indexes concurrently
  • Loading branch information
witash authored Dec 11, 2024
1 parent 5f52f33 commit 0e6b671
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions couch2pg/src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ CREATE TABLE IF NOT EXISTS ${db.postgresProgressTable} (
);`;

const createDeleteIndex = `
CREATE INDEX IF NOT EXISTS _deleted ON ${db.postgresTable}(_deleted);
CREATE INDEX CONCURRENTLY IF NOT EXISTS _deleted ON ${db.postgresTable}(_deleted);
`;

const createTimestampIndex = `
CREATE INDEX IF NOT EXISTS saved_timestamp ON ${db.postgresTable}(saved_timestamp);
CREATE INDEX CONCURRENTLY IF NOT EXISTS saved_timestamp ON ${db.postgresTable}(saved_timestamp);
`;

export const createDatabase = async () => {
Expand Down
4 changes: 2 additions & 2 deletions couch2pg/tests/unit/setup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ CREATE TABLE IF NOT EXISTS v1.whatever (
doc jsonb
)`]);
expect(pgClient.query.args[2]).to.deep.equal([`
CREATE INDEX IF NOT EXISTS _deleted ON v1.whatever(_deleted);
CREATE INDEX CONCURRENTLY IF NOT EXISTS _deleted ON v1.whatever(_deleted);
`]);
expect(pgClient.query.args[3]).to.deep.equal([`
CREATE INDEX IF NOT EXISTS saved_timestamp ON v1.whatever(saved_timestamp);
CREATE INDEX CONCURRENTLY IF NOT EXISTS saved_timestamp ON v1.whatever(saved_timestamp);
`]);
expect(pgClient.query.args[4]).to.deep.equal([`
CREATE TABLE IF NOT EXISTS v1.couchdb_progress (
Expand Down

0 comments on commit 0e6b671

Please sign in to comment.