fix most_recent_crawl table for dead instances

This commit is contained in:
Tao Bror Bojlén 2019-08-20 10:10:03 +02:00
parent 617e2f43ee
commit 7427a78b65
No known key found for this signature in database
GPG Key ID: C6EC7AAB905F9E6F
2 changed files with 27 additions and 0 deletions

View File

@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Added ON DELETE to `most_recent_crawl` table, such that it can handle previously-crawled but now-dead instances.
## [2.7.0 - 2018-08-18]
### Added

View File

@ -0,0 +1,25 @@
defmodule Backend.Repo.Migrations.AddMostRecentCrawlOnDelete do
use Ecto.Migration
def change do
execute(
"ALTER TABLE most_recent_crawl DROP CONSTRAINT most_recent_crawl_crawl_id_fkey",
"ALTER TABLE most_recent_crawl ADD CONSTRAINT most_recent_crawl_crawl_id_fkey FOREIGN KEY (crawl_id) REFERENCES crawls(id)"
)
execute(
"ALTER TABLE most_recent_crawl ADD CONSTRAINT most_recent_crawl_crawl_id_fkey FOREIGN KEY (crawl_id) REFERENCES crawls(id) ON DELETE CASCADE",
"ALTER TABLE most_recent_crawl DROP CONSTRAINT most_recent_crawl_crawl_id_fkey"
)
execute(
"ALTER TABLE most_recent_crawl DROP CONSTRAINT most_recent_crawl_instance_domain_fkey",
"ALTER TABLE most_recent_crawl ADD CONSTRAINT most_recent_crawl_instance_domain_fkey FOREIGN KEY (instance_domain) REFERENCES instances(domain)"
)
execute(
"ALTER TABLE most_recent_crawl ADD CONSTRAINT most_recent_crawl_instance_domain_fkey FOREIGN KEY (instance_domain) REFERENCES instances(domain) ON DELETE CASCADE",
"ALTER TABLE most_recent_crawl DROP CONSTRAINT most_recent_crawl_instance_domain_fkey"
)
end
end