Skip to content

Commit

Permalink
use unique index and separate database migration
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Li <[email protected]>
  • Loading branch information
ryli17 committed Oct 22, 2020
1 parent 887f2b8 commit 6a401d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 0 additions & 3 deletions db/migration/202009171251-init-database.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ CREATE TABLE IF NOT EXISTS workflow_worker_map (
, worker_id UUID NOT NULL
);
ALTER TABLE workflow_worker_map DROP CONSTRAINT IF EXISTS workflow_worker_pkey;
ALTER TABLE workflow_worker_map ADD CONSTRAINT workflow_worker_pkey PRIMARY KEY (workflow_id, worker_id);
CREATE TABLE IF NOT EXISTS workflow_data (
workflow_id UUID NOT NULL
, version INT
Expand Down
12 changes: 12 additions & 0 deletions db/migration/202010221010-add-unique-index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package migration

import migrate "github.com/rubenv/sql-migrate"

func Get202010221010() *migrate.Migration {
return &migrate.Migration{
Id: "202010221010-add-unique-index",
Up: []string{`
CREATE UNIQUE INDEX IF NOT EXISTS uidx_workflow_worker_map ON workflow_worker_map (workflow_id, worker_id);
`},
}
}
1 change: 1 addition & 0 deletions db/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ func GetMigrations() *migrate.MemoryMigrationSource {
return &migrate.MemoryMigrationSource{
Migrations: []*migrate.Migration{
Get202009171251(),
Get202010221010(),
},
}
}

0 comments on commit 6a401d4

Please sign in to comment.