Skip to content

Commit 2a8febf

Browse files
authored
add support to drop db constraints (#1598)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent e7080bb commit 2a8febf

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

app/controlplane/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ migration_apply: check-atlas-tool migration_hash
3636
.PHONY: migration_sync
3737
# sync migration files with the current ent schema
3838
migration_sync: check-atlas-tool migration_hash
39-
atlas migrate diff --dir ${local_migrations_dir} --to "ent://pkg/data/ent/schema" --dev-url "docker://postgres/15/test?search_path=public"
39+
atlas migrate diff --dir ${local_migrations_dir} --to "ent://pkg/data/ent/schema" --dev-url "docker://postgres/15/test?search_path=public" --config file://atlas.hcl --env dev
40+
41+
migration_lint: check-atlas-tool migration_hash
42+
atlas migrate lint --dir ${local_migrations_dir} --dev-url "docker://postgres/15/test?search_path=public" --latest 1 --config file://atlas.hcl --env dev
4043

4144
.PHONY: migration_new
4245
# generate an empty migration file

app/controlplane/atlas.hcl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# do not add automatically foreign keys to the generated migrations
2+
env "dev" {
3+
diff {
4+
skip {
5+
add_foreign_key = true
6+
}
7+
}
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- remove constraints for performance reasons
2+
ALTER TABLE public.workflow_run_cas_backends DROP CONSTRAINT workflow_run_cas_backends_workflow_run_id;
3+
ALTER TABLE public.workflow_run_cas_backends DROP CONSTRAINT workflow_run_cas_backends_cas_backend_id;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- remove for performance reasons
2+
ALTER TABLE cas_mappings DROP CONSTRAINT cas_mappings_cas_backends_cas_backend;
3+
ALTER TABLE cas_mappings DROP CONSTRAINT cas_mappings_organizations_organization;

app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:J//lNzTG1omhRdZO5iV295VWI2N70PBO9u1SqN2Pxj0=
1+
h1:cd7peHu3MdqEo1c6vGrDGeDjSLGEFrPqrrEiSMDZJp0=
22
20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M=
33
20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g=
44
20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI=
@@ -67,3 +67,5 @@ h1:J//lNzTG1omhRdZO5iV295VWI2N70PBO9u1SqN2Pxj0=
6767
20241122101039.sql h1:RMk8MDWj/RhbVKX9ERHEI96tFFPuMEwNZMk65FanOvM=
6868
20241123161902.sql h1:Nm0Szr+lGbXWCE6KS8aIsd2mz2GadWOuF36o2uHaT70=
6969
20241123163942.sql h1:s+ImKf84B5s3Hp9Q7ILTcbNkQFIveZapu8fSe3X0eLY=
70+
20241126164629.sql h1:TrYF9F2RmBUVVB/9a3XFlintq94b2/BaJLYjv80TXOQ=
71+
20241126182209.sql h1:01eeRbQxKYsjhEvafp1fL4kYJx4NoidwjcxWbWLlNak=

0 commit comments

Comments
 (0)