forked from gobuffalo/fizz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle foreign keys and indices properly in SQLite and add e2e tests
This patch resolves issues with `change_column` and `drop_column` which previously caused duplicate or missing indices and foreign keys. To prevent future regressions and help debugging, a new e2e-test pipeline has been added to the project and the CI. Documentation for running the tests has been added to the README. End-to-end tests currently support MySQL, PostgreSQL, and SQLite and do not yet cover other SQL flavors. During review, please help ensure that the SQL fixtures are not missing something :) Closes gobuffalo#92
- Loading branch information
Showing
39 changed files
with
1,612 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,14 @@ test: | |
./test.sh | ||
make tidy | ||
|
||
test-e2e: | ||
docker rm -f gobuffalo_fizz_test_database_mysql gobuffalo_fizz_test_database_postgres gobuffalo_fizz_test_database_cockroach || true | ||
docker run --name gobuffalo_fizz_test_database_postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres -d postgres:10.8 | ||
docker run --name gobuffalo_fizz_test_database_mysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=pop_test -e MYSQL_PORT=3307 -d mysql:5.7 | ||
SODA_DIALECT=sqlite go test -tags sqlite ./internal/integration | ||
SODA_DIALECT=postgres POSTGRES_URL=postgres://postgres:[email protected]:5432/postgres?sslmode=disable go test -tags sqlite ./internal/integration | ||
SODA_DIALECT=mysql MYSQL_URL="mysql://root:root@tcp(127.0.0.1:3307)/pop_test?parseTime=true&multiStatements=true" go test -tags sqlite ./internal/integration | ||
|
||
ci-deps: | ||
$(GO_BIN) get -tags ${TAGS} -t ./... | ||
|
||
|
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,40 @@ | ||
-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) | ||
-- | ||
-- Host: 127.0.0.1 Database: pop_test | ||
-- ------------------------------------------------------ | ||
-- Server version 5.7.30 | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!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' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- | ||
-- Table structure for table `schema_migration` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `schema_migration`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `schema_migration` ( | ||
`version` varchar(14) NOT NULL, | ||
UNIQUE KEY `schema_migration_version_idx` (`version`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
||
-- Dump completed on 2020-06-20 13:06:39 |
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,55 @@ | ||
-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) | ||
-- | ||
-- Host: 127.0.0.1 Database: pop_test | ||
-- ------------------------------------------------------ | ||
-- Server version 5.7.30 | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!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' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- | ||
-- Table structure for table `schema_migration` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `schema_migration`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `schema_migration` ( | ||
`version` varchar(14) NOT NULL, | ||
UNIQUE KEY `schema_migration_version_idx` (`version`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `users`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `users` ( | ||
`id` char(36) NOT NULL, | ||
`created_at` datetime NOT NULL, | ||
`updated_at` datetime NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
||
-- Dump completed on 2020-06-20 13:06:39 |
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,76 @@ | ||
-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) | ||
-- | ||
-- Host: 127.0.0.1 Database: pop_test | ||
-- ------------------------------------------------------ | ||
-- Server version 5.7.30 | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!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' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- | ||
-- Table structure for table `schema_migration` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `schema_migration`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `schema_migration` ( | ||
`version` varchar(14) NOT NULL, | ||
UNIQUE KEY `schema_migration_version_idx` (`version`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Table structure for table `user_notes` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `user_notes`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `user_notes` ( | ||
`id` char(36) NOT NULL, | ||
`notes` varchar(255) NOT NULL, | ||
`user_id` char(36) NOT NULL, | ||
`created_at` datetime NOT NULL, | ||
`updated_at` datetime NOT NULL, | ||
`title` varchar(64) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `user_notes_user_id_idx` (`user_id`), | ||
KEY `user_notes_title_idx` (`title`), | ||
CONSTRAINT `user_notes_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `users`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `users` ( | ||
`id` char(36) NOT NULL, | ||
`created_at` datetime NOT NULL, | ||
`updated_at` datetime NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
||
-- Dump completed on 2020-06-20 13:06:39 |
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,55 @@ | ||
-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) | ||
-- | ||
-- Host: 127.0.0.1 Database: pop_test | ||
-- ------------------------------------------------------ | ||
-- Server version 5.7.30 | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!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' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- | ||
-- Table structure for table `schema_migration` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `schema_migration`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `schema_migration` ( | ||
`version` varchar(14) NOT NULL, | ||
UNIQUE KEY `schema_migration_version_idx` (`version`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `users`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `users` ( | ||
`id` char(36) NOT NULL, | ||
`created_at` datetime NOT NULL, | ||
`updated_at` datetime NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
||
-- Dump completed on 2020-06-20 13:02:59 |
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,76 @@ | ||
-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) | ||
-- | ||
-- Host: 127.0.0.1 Database: pop_test | ||
-- ------------------------------------------------------ | ||
-- Server version 5.7.30 | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!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' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- | ||
-- Table structure for table `schema_migration` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `schema_migration`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `schema_migration` ( | ||
`version` varchar(14) NOT NULL, | ||
UNIQUE KEY `schema_migration_version_idx` (`version`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Table structure for table `user_notes` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `user_notes`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `user_notes` ( | ||
`id` char(36) NOT NULL, | ||
`notes` varchar(255) NOT NULL, | ||
`title` varchar(64) NOT NULL, | ||
`user_id` char(36) NOT NULL, | ||
`created_at` datetime NOT NULL, | ||
`updated_at` datetime NOT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `user_notes_user_id_idx` (`user_id`), | ||
KEY `user_notes_title_idx` (`title`), | ||
CONSTRAINT `user_notes_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `users`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `users` ( | ||
`id` char(36) NOT NULL, | ||
`created_at` datetime NOT NULL, | ||
`updated_at` datetime NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
||
-- Dump completed on 2020-06-20 13:03:00 |
Oops, something went wrong.