-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because - pipeline requires various statuses to reflect its situation This commit - bridge enum type defined in the db and protobuf - close #43 - close #44
- Loading branch information
Showing
26 changed files
with
187 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE "pipeline_history" DROP CONSTRAINT IF EXISTS "pipeline_history_fk_pipeline_id"; | ||
|
||
DROP TABLE IF EXISTS "pipeline_history"; | ||
|
||
DROP TABLE IF EXISTS "pipelines"; | ||
DROP TABLE IF EXISTS pipelines; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,23 @@ | ||
BEGIN; | ||
|
||
CREATE TABLE IF NOT EXISTS "pipelines" ( | ||
"id" SERIAL PRIMARY KEY, | ||
"ext_id" varchar(20) NOT NULL, | ||
"name" varchar(256) NOT NULL, | ||
"description" text, | ||
"enabled" boolean NOT NULL DEFAULT (false), | ||
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
"deleted_at" timestamp, | ||
"recipe" JSONB, | ||
"crontab" varchar(13) | ||
CREATE TABLE IF NOT EXISTS pipelines ( | ||
id SERIAL PRIMARY KEY, | ||
ext_id varchar(20) NOT NULL, | ||
name varchar(256) NOT NULL, | ||
description text, | ||
enabled boolean NOT NULL DEFAULT (false), | ||
created_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
updated_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
deleted_at timestamp, | ||
recipe JSONB, | ||
crontab varchar(13) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "pipeline_history" ( | ||
"pipeline_id" int NOT NULL, | ||
"recipe" JSONB NOT NULL, | ||
"version" int NOT NULL, | ||
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
PRIMARY KEY ("pipeline_id", "version") | ||
); | ||
|
||
COMMENT ON COLUMN "pipelines"."ext_id" IS 'the hash of the id'; | ||
COMMENT ON COLUMN "pipelines"."name" IS 'name of this pipeline'; | ||
COMMENT ON COLUMN "pipelines"."description" IS 'description of this pipeline'; | ||
COMMENT ON COLUMN "pipelines"."enabled" IS 'activate/deactivate pipeline'; | ||
COMMENT ON COLUMN "pipelines"."recipe" IS 'describe what the pipeline looks like'; | ||
COMMENT ON COLUMN "pipelines"."crontab" IS 'the 6 * crontab format'; | ||
|
||
COMMENT ON COLUMN "pipeline_history"."recipe" IS 'describe what the pipeline looks like'; | ||
|
||
ALTER TABLE "pipeline_history" ADD CONSTRAINT "pipeline_history_fk_pipeline_id" FOREIGN KEY ("pipeline_id") REFERENCES "pipelines"("id"); | ||
COMMENT ON COLUMN pipelines.ext_id IS 'the hash of the id'; | ||
COMMENT ON COLUMN pipelines.name IS 'name of this pipeline'; | ||
COMMENT ON COLUMN pipelines.description IS 'description of this pipeline'; | ||
COMMENT ON COLUMN pipelines.enabled IS 'activate/deactivate pipeline'; | ||
COMMENT ON COLUMN pipelines.recipe IS 'pipeline configration'; | ||
COMMENT ON COLUMN pipelines.crontab IS 'the 6 * crontab format'; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE "pipelines" DROP "creator_id"; | ||
ALTER TABLE pipelines DROP creator_id; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE "pipelines" ADD "creator_id" varchar(36) NOT NULL; | ||
ALTER TABLE pipelines ADD creator_id varchar(36) NOT NULL; | ||
|
||
COMMIT; |
2 changes: 1 addition & 1 deletion
2
internal/db/migration/000003_change_enabled_column_name.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE "pipelines" RENAME COLUMN "active" TO "enabled"; | ||
ALTER TABLE pipelines RENAME COLUMN active TO enabled; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE "pipelines" RENAME COLUMN "enabled" TO "active"; | ||
ALTER TABLE pipelines RENAME COLUMN enabled TO active; | ||
|
||
COMMIT; |
22 changes: 10 additions & 12 deletions
22
internal/db/migration/000004_human_readable_name.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE "pipelines" ALTER COLUMN "id" SET DATA TYPE INT; | ||
ALTER TABLE pipelines DROP CONSTRAINT unique_name_namespace; | ||
|
||
ALTER TABLE "pipelines" DROP CONSTRAINT "unique_name_namespace"; | ||
ALTER TABLE pipelines DROP COLUMN IF EXISTS namespace; | ||
|
||
ALTER TABLE "pipelines" DROP COLUMN IF EXISTS "namespace"; | ||
ALTER TABLE pipelines ADD ext_id varchar(20) NOT NULL DEFAULT '000004'; | ||
COMMENT ON COLUMN pipelines.ext_id IS 'the hash of the id'; | ||
|
||
ALTER TABLE "pipelines" ADD "ext_id" varchar(20) NOT NULL DEFAULT '000004'; | ||
COMMENT ON COLUMN "pipelines"."ext_id" IS 'the hash of the id'; | ||
ALTER TABLE pipelines ADD creator_id varchar(36) NOT NULL DEFAULT '000004'; | ||
|
||
ALTER TABLE "pipelines" ADD "creator_id" varchar(36) NOT NULL DEFAULT '000004'; | ||
UPDATE pipelines | ||
SET ext_id = migration.ext_id, creator_id = migration.creator_id | ||
FROM pipelines_migration AS migration | ||
WHERE pipelines.id = migration.id; | ||
|
||
UPDATE "pipelines" | ||
SET "ext_id" = bak."ext_id", "creator_id" = bak."creator_id" | ||
FROM "pipelines_bak" AS bak | ||
WHERE "pipelines"."id" = bak."id"; | ||
|
||
DROP TABLE IF EXISTS "pipelines_bak"; | ||
DROP TABLE IF EXISTS pipelines_migration; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
BEGIN; | ||
|
||
CREATE TABLE IF NOT EXISTS "pipelines_bak" AS TABLE "pipelines"; | ||
CREATE TABLE IF NOT EXISTS pipelines_migration AS TABLE pipelines; | ||
|
||
ALTER TABLE "pipelines" DROP COLUMN IF EXISTS "ext_id"; | ||
ALTER TABLE "pipelines" DROP COLUMN IF EXISTS "creator_id"; | ||
ALTER TABLE pipelines DROP COLUMN IF EXISTS ext_id; | ||
ALTER TABLE pipelines DROP COLUMN IF EXISTS creator_id; | ||
|
||
ALTER TABLE "pipelines" ADD "namespace" varchar(39) NOT NULL DEFAULT 'undefined'; | ||
COMMENT ON COLUMN "pipelines"."namespace" IS 'a set of pipelines'; | ||
ALTER TABLE pipelines ADD namespace varchar(39) NOT NULL DEFAULT 'undefined'; | ||
COMMENT ON COLUMN pipelines.namespace IS 'namespace in which the pipeline belongs to'; | ||
|
||
ALTER TABLE "pipelines" ADD CONSTRAINT "unique_name_namespace" UNIQUE ("name", "deleted_at", "namespace"); | ||
|
||
ALTER TABLE "pipelines" ALTER COLUMN "id" SET DATA TYPE BIGINT; | ||
ALTER TABLE pipelines ADD CONSTRAINT unique_name_namespace UNIQUE (name, deleted_at, namespace); | ||
|
||
COMMIT; |
7 changes: 7 additions & 0 deletions
7
internal/db/migration/000005_rename_pipeline_table_to_singular.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE pipeline RENAME TO pipelines; | ||
|
||
ALTER TABLE pipelines RENAME CONSTRAINT pipeline_pkey TO pipelines_pkey; | ||
|
||
COMMIT; |
7 changes: 7 additions & 0 deletions
7
internal/db/migration/000005_rename_pipeline_table_to_singular.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE pipelines RENAME TO pipeline; | ||
|
||
ALTER TABLE pipeline RENAME CONSTRAINT pipelines_pkey TO pipeline_pkey; | ||
|
||
COMMIT; |
14 changes: 14 additions & 0 deletions
14
internal/db/migration/000006_add_pipeline_status_column.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE pipeline ALTER COLUMN status DROP DEFAULT; | ||
|
||
ALTER TABLE pipeline ALTER COLUMN status TYPE boolean | ||
USING CASE WHEN status='STATUS_INACTIVE'::valid_status THEN FALSE ELSE TRUE END; | ||
|
||
ALTER TABLE pipeline ALTER COLUMN status SET DEFAULT FALSE; | ||
|
||
ALTER TABLE pipeline RENAME COLUMN status TO active; | ||
|
||
DROP TYPE valid_status; | ||
|
||
COMMIT; |
16 changes: 16 additions & 0 deletions
16
internal/db/migration/000006_add_pipeline_status_column.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
BEGIN; | ||
|
||
CREATE TYPE valid_status AS ENUM ('STATUS_INACTIVE', 'STATUS_ACTIVE', 'STATUS_ERROR'); | ||
|
||
ALTER TABLE pipeline RENAME COLUMN active TO status; | ||
|
||
ALTER TABLE pipeline ALTER COLUMN status DROP DEFAULT; | ||
|
||
ALTER TABLE pipeline ALTER COLUMN status TYPE valid_status | ||
USING CASE WHEN status=FALSE THEN 'STATUS_INACTIVE'::valid_status ELSE 'STATUS_ACTIVE'::valid_status END; | ||
|
||
ALTER TABLE pipeline ALTER COLUMN status SET DEFAULT 'STATUS_INACTIVE'::valid_status; | ||
|
||
COMMENT ON COLUMN pipeline.status IS 'pipeline status'; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.