-
Notifications
You must be signed in to change notification settings - Fork 8
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 #29 from skpr/provider-model
Implement a provider model for RDS/Stdout mysql providers.
- Loading branch information
Showing
19 changed files
with
532 additions
and
236 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/*!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 utf8mb4 */; | ||
/*!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 */; | ||
|
||
-- | ||
-- Structure for table `orders` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `orders`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `orders` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`user_id` int DEFAULT NULL, | ||
`total_amount` decimal(10,2) NOT NULL, | ||
`order_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`), | ||
KEY `user_id` (`user_id`), | ||
CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Data for table `orders` -- 3 rows | ||
-- | ||
|
||
LOCK TABLES `orders` WRITE; | ||
/*!40000 ALTER TABLE `orders` DISABLE KEYS */; | ||
set autocommit=0; | ||
INSERT INTO `orders` VALUES (1,1,'1079.98','2024-06-27 04:48:24'),(2,2,'499.99','2024-06-27 04:48:24'),(3,3,'579.98','2024-06-27 04:48:24'); | ||
/*!40000 ALTER TABLE `orders` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
commit; | ||
|
||
-- | ||
-- Structure for table `products` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `products`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `products` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`name` varchar(100) NOT NULL, | ||
`price` decimal(10,2) NOT NULL, | ||
`stock` int NOT NULL DEFAULT '0', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Data for table `products` -- 3 rows | ||
-- | ||
|
||
LOCK TABLES `products` WRITE; | ||
/*!40000 ALTER TABLE `products` DISABLE KEYS */; | ||
set autocommit=0; | ||
INSERT INTO `products` VALUES (1,'Laptop','999.99',50),(2,'Smartphone','499.99',100),(3,'Headphones','79.99',200); | ||
/*!40000 ALTER TABLE `products` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
commit; | ||
|
||
-- | ||
-- 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` int NOT NULL AUTO_INCREMENT, | ||
`username` varchar(50) NOT NULL, | ||
`email` varchar(100) NOT NULL, | ||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `username` (`username`), | ||
UNIQUE KEY `email` (`email`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Data for table `users` -- 3 rows | ||
-- | ||
|
||
LOCK TABLES `users` WRITE; | ||
/*!40000 ALTER TABLE `users` DISABLE KEYS */; | ||
set autocommit=0; | ||
INSERT INTO `users` VALUES (1,'john_doe','john@example.com','2024-06-27 04:48:24'),(2,'jane_smith','jane@example.com','2024-06-27 04:48:24'),(3,'bob_johnson','bob@example.com','2024-06-27 04:48:24'); | ||
/*!40000 ALTER TABLE `users` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
commit; | ||
/*!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 */; |
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,48 @@ | ||
name: Functional Test | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: ['main'] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Build MTK | ||
run: make build | ||
|
||
- name: MySQL:Start | ||
run: sudo /etc/init.d/mysql start | ||
|
||
- name: Database:Create | ||
run: mysql -e 'CREATE DATABASE test_db;' -uroot -proot | ||
|
||
- name: Database:Import | ||
run: mysql -uroot -proot test_db < .github/workflows/functional-test.sql | ||
|
||
- name: Database:Dump | ||
run: bin/mtk-linux-amd64 dump test_db --port=3306 --user=root --password=root --host=127.0.0.1 > mtk-dump.sql | ||
|
||
- name: Database:Drop | ||
run: mysql -e 'DROP DATABASE test_db;' -uroot -proot | ||
|
||
- name: Database:Clean | ||
# Remove the last line from the file - the dump timestamp. | ||
run: sed '$d' mtk-dump.sql > mtk-dump-clean.sql | ||
|
||
- name: Database:Recreate | ||
run: mysql -e 'CREATE DATABASE test_db;' -uroot -proot | ||
|
||
- name: Database:Reimport | ||
run: mysql -uroot -proot test_db < mtk-dump-clean.sql | ||
|
||
- name: Compare results | ||
run: diff -q .github/workflows/functional-test.sql mtk-dump-clean.sql |
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
Oops, something went wrong.