Skip to content

Commit

Permalink
add support to drop db constraints (#1598)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Martinez <[email protected]>
  • Loading branch information
migmartri authored Nov 26, 2024
1 parent e7080bb commit 2a8febf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/controlplane/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ migration_apply: check-atlas-tool migration_hash
.PHONY: migration_sync
# sync migration files with the current ent schema
migration_sync: check-atlas-tool migration_hash
atlas migrate diff --dir ${local_migrations_dir} --to "ent://pkg/data/ent/schema" --dev-url "docker://postgres/15/test?search_path=public"
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

migration_lint: check-atlas-tool migration_hash
atlas migrate lint --dir ${local_migrations_dir} --dev-url "docker://postgres/15/test?search_path=public" --latest 1 --config file://atlas.hcl --env dev

.PHONY: migration_new
# generate an empty migration file
Expand Down
8 changes: 8 additions & 0 deletions app/controlplane/atlas.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# do not add automatically foreign keys to the generated migrations
env "dev" {
diff {
skip {
add_foreign_key = true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- remove constraints for performance reasons
ALTER TABLE public.workflow_run_cas_backends DROP CONSTRAINT workflow_run_cas_backends_workflow_run_id;
ALTER TABLE public.workflow_run_cas_backends DROP CONSTRAINT workflow_run_cas_backends_cas_backend_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- remove for performance reasons
ALTER TABLE cas_mappings DROP CONSTRAINT cas_mappings_cas_backends_cas_backend;
ALTER TABLE cas_mappings DROP CONSTRAINT cas_mappings_organizations_organization;
4 changes: 3 additions & 1 deletion app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:J//lNzTG1omhRdZO5iV295VWI2N70PBO9u1SqN2Pxj0=
h1:cd7peHu3MdqEo1c6vGrDGeDjSLGEFrPqrrEiSMDZJp0=
20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M=
20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g=
20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI=
Expand Down Expand Up @@ -67,3 +67,5 @@ h1:J//lNzTG1omhRdZO5iV295VWI2N70PBO9u1SqN2Pxj0=
20241122101039.sql h1:RMk8MDWj/RhbVKX9ERHEI96tFFPuMEwNZMk65FanOvM=
20241123161902.sql h1:Nm0Szr+lGbXWCE6KS8aIsd2mz2GadWOuF36o2uHaT70=
20241123163942.sql h1:s+ImKf84B5s3Hp9Q7ILTcbNkQFIveZapu8fSe3X0eLY=
20241126164629.sql h1:TrYF9F2RmBUVVB/9a3XFlintq94b2/BaJLYjv80TXOQ=
20241126182209.sql h1:01eeRbQxKYsjhEvafp1fL4kYJx4NoidwjcxWbWLlNak=

0 comments on commit 2a8febf

Please sign in to comment.