add on delete cascade to crawl interactions

This commit is contained in:
Tao Bror Bojlén 2019-08-21 22:40:42 +02:00
parent 55f55216d6
commit 0a3e1e638c
No known key found for this signature in database
GPG key ID: C6EC7AAB905F9E6F

View file

@ -0,0 +1,25 @@
defmodule Backend.Repo.Migrations.AddCrawlInteractionOnDelete do
use Ecto.Migration
def change do
execute(
"ALTER TABLE crawl_interactions DROP CONSTRAINT crawl_interactions_source_domain_fkey",
"ALTER TABLE crawl_interactions ADD CONSTRAINT crawl_interactions_source_domain_fkey FOREIGN KEY (source_domain) REFERENCES instances(domain)"
)
execute(
"ALTER TABLE crawl_interactions ADD CONSTRAINT crawl_interactions_source_domain_fkey FOREIGN KEY (source_domain) REFERENCES instances(domain) ON DELETE CASCADE",
"ALTER TABLE crawl_interactions DROP CONSTRAINT crawl_interactions_source_domain_fkey"
)
execute(
"ALTER TABLE crawl_interactions DROP CONSTRAINT crawl_interactions_target_domain_fkey",
"ALTER TABLE crawl_interactions ADD CONSTRAINT crawl_interactions_target_domain_fkey FOREIGN KEY (target_domain) REFERENCES instances(domain)"
)
execute(
"ALTER TABLE crawl_interactions ADD CONSTRAINT crawl_interactions_target_domain_fkey FOREIGN KEY (target_domain) REFERENCES instances(domain) ON DELETE CASCADE",
"ALTER TABLE crawl_interactions DROP CONSTRAINT crawl_interactions_target_domain_fkey"
)
end
end