Skip to content

Commit

Permalink
Update migration 00030_host_sectors (#1713)
Browse files Browse the repository at this point in the history
DB shouldn't have these tables but seems like I forgot to add `DROP
TABLE IF EXISTS` statements.
  • Loading branch information
ChrisSchinnerl authored Dec 4, 2024
2 parents 50c650a + 381aba6 commit 9742d26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix_migration_00030_host_sectors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: minor
---

# Fix 00030_host_sectors migration on DBs that have a host_sectors table
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DROP TABLE IF EXISTS `host_sectors`;

CREATE TABLE `host_sectors` (
`updated_at` datetime(3) DEFAULT NULL,
`db_sector_id` bigint unsigned NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DROP TABLE IF EXISTS `host_sectors`;

CREATE TABLE `host_sectors` (`updated_at` datetime, `db_sector_id` integer,`db_host_id` integer,PRIMARY KEY (`db_sector_id`,`db_host_id`),CONSTRAINT `fk_host_sectors_db_sector` FOREIGN KEY (`db_sector_id`) REFERENCES `sectors`(`id`) ON DELETE CASCADE,CONSTRAINT `fk_contract_sectors_db_host` FOREIGN KEY (`db_host_id`) REFERENCES `hosts`(`id`) ON DELETE CASCADE);
CREATE INDEX `idx_host_sectors_updated_at` ON `host_sectors`(`updated_at`);
CREATE INDEX `idx_host_sectors_db_host_id` ON `host_sectors`(`db_host_id`);
Expand Down

0 comments on commit 9742d26

Please sign in to comment.