Skip to content

Commit

Permalink
fix: fix enum invalid value
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Oct 8, 2024
1 parent 4e3724b commit 4784b35
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 23 additions & 0 deletions apps/backend/db/migrations/20241008035928_fix-enum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @param {import('knex').Knex} knex
*/
export const up = async (knex) => {
await knex.raw(
`ALTER TABLE builds DROP CONSTRAINT "builds_baseBranchResolvedFrom_check"`,
);
await knex.raw(
`ALTER TABLE builds ADD CONSTRAINT "builds_baseBranchResolvedFrom_check" CHECK ("baseBranchResolvedFrom" = ANY (ARRAY['user'::text, 'pull-request'::text, 'project'::text]))`,
);
};

/**
* @param {import('knex').Knex} knex
*/
export const down = async (knex) => {
await knex.raw(
`ALTER TABLE builds DROP CONSTRAINT "builds_baseBranchResolvedFrom_check"`,
);
await knex.raw(
`ALTER TABLE builds ADD CONSTRAINT "builds_baseBranchResolvedFrom_check" CHECK ("baseBranchResolvedFrom" = ANY (ARRAY['sdk'::text, 'pull-request'::text, 'project'::text]))`,
);
};
5 changes: 3 additions & 2 deletions apps/backend/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ CREATE TABLE public.builds (
partial boolean DEFAULT false NOT NULL,
metadata jsonb,
"baseBranchResolvedFrom" text,
CONSTRAINT "builds_baseBranchResolvedFrom_check" CHECK (("baseBranchResolvedFrom" = ANY (ARRAY['sdk'::text, 'pull-request'::text, 'project'::text]))),
CONSTRAINT "builds_baseBranchResolvedFrom_check" CHECK (("baseBranchResolvedFrom" = ANY (ARRAY['user'::text, 'pull-request'::text, 'project'::text]))),
CONSTRAINT builds_mode_check CHECK ((mode = ANY (ARRAY['ci'::text, 'monitoring'::text]))),
CONSTRAINT builds_type_check CHECK ((type = ANY (ARRAY['reference'::text, 'check'::text, 'orphan'::text])))
);
Expand Down Expand Up @@ -2836,4 +2836,5 @@ INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('2024063
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20240706121810_screenshot-base-name.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20240822082247_github-light.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20240901150444_build-metadata.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20241006153157_reference-branch.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20241006153157_reference-branch.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20241008035928_fix-enum.js', 1, NOW());

0 comments on commit 4784b35

Please sign in to comment.