-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from camcima/hotfix/table-drops
DROP first
- Loading branch information
Showing
8 changed files
with
110 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- -------------------------------------------------------- | ||
-- Host: 127.0.0.1 | ||
-- Server version: 5.7.10-log - MySQL Community Server (GPL) | ||
-- Server OS: Win64 | ||
-- HeidiSQL Version: 9.4.0.5174 | ||
-- -------------------------------------------------------- | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!50503 SET NAMES utf8mb4 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
|
||
-- Dumping structure for table sakila.table_1 | ||
CREATE TABLE IF NOT EXISTS `table_1` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`foreignId` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `FK_table_1_table_2` (`foreignId`), | ||
CONSTRAINT `FK_table_1_table_2` FOREIGN KEY (`foreignId`) REFERENCES `table_2` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='.'; | ||
|
||
-- Data exporting was unselected. | ||
-- Dumping structure for table sakila.table_2 | ||
CREATE TABLE IF NOT EXISTS `table_2` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='.'; | ||
|
||
-- Data exporting was unselected. | ||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- Host: 127.0.0.1 Database: test_2 | ||
|
||
DROP TABLE IF EXISTS `table_1`; | ||
CREATE TABLE `table_1` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`foreignId2` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `FK_table_1_table_2` (`foreignId2`), | ||
CONSTRAINT `FK_table_1_table_2` FOREIGN KEY (`foreignId2`) REFERENCES `table_2` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='.'; | ||
|
||
|
||
DROP TABLE IF EXISTS `table_2`; | ||
CREATE TABLE `table_2` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='.'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Disable Foreign Keys Check | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
SET SQL_MODE = ''; | ||
|
||
# Deleted Tables | ||
|
||
# Changed Tables | ||
|
||
-- changed table `table_1` | ||
|
||
ALTER TABLE `table_1` | ||
DROP FOREIGN KEY `FK_table_1_table_2`, | ||
DROP INDEX `FK_table_1_table_2`, | ||
DROP COLUMN `foreignId`; | ||
ALTER TABLE `table_1` | ||
ADD COLUMN `foreignId2` int(11) DEFAULT NULL AFTER `id`, | ||
ADD KEY `FK_table_1_table_2` (`foreignId2`), | ||
ADD CONSTRAINT `FK_table_1_table_2` FOREIGN KEY (`foreignId2`) REFERENCES `table_2` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; | ||
|
||
# New Tables | ||
|
||
# Disable Foreign Keys Check | ||
SET FOREIGN_KEY_CHECKS = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters