mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +01:00
simplify sql create tables
This commit is contained in:
parent
048f4fd884
commit
16bfb1cf2f
@ -18,11 +18,11 @@ $ pwd
|
|||||||
The `sql` directory contains the SQL files used for database setup:
|
The `sql` directory contains the SQL files used for database setup:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mysql -u root -p < sql/create_database.sql
|
mysql -u root -p < sql/0_create_database.sql
|
||||||
mysql -u root -p my_bank < sql/bank_details.sql
|
mysql -u root -p my_bank < sql/1_bank_details.sql
|
||||||
mysql -u root -p my_bank < sql/branch_details.sql
|
mysql -u root -p my_bank < sql/2_branch_details.sql
|
||||||
mysql -u root -p my_bank < sql/teller_details.sql
|
mysql -u root -p my_bank < sql/3_teller_details.sql
|
||||||
mysql -u root -p my_bank < sql/customer_details.sql
|
mysql -u root -p my_bank < sql/4_customer_details.sql
|
||||||
```
|
```
|
||||||
|
|
||||||
For each step you will be prompted for the root user's password. If there's no password set on the root use, just hit enter again.
|
For each step you will be prompted for the root user's password. If there's no password set on the root use, just hit enter again.
|
||||||
|
6
databases/mysql/sql/1_bank_details.sql
Normal file
6
databases/mysql/sql/1_bank_details.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE `bank_details` (
|
||||||
|
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`bank_name` VARCHAR(30) NOT NULL,
|
||||||
|
`country` VARCHAR(30) NOT NULL,
|
||||||
|
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) CHARSET=utf8mb4;
|
6
databases/mysql/sql/2_branch_details.sql
Normal file
6
databases/mysql/sql/2_branch_details.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE `branch_details` (
|
||||||
|
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`branch_name` VARCHAR(30) NOT NULL,
|
||||||
|
`location` VARCHAR(30) NOT NULL,
|
||||||
|
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) CHARSET=utf8mb4;
|
6
databases/mysql/sql/3_customer_details.sql
Normal file
6
databases/mysql/sql/3_customer_details.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE `customer_details` (
|
||||||
|
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`customer_name` VARCHAR(100) NOT NULL,
|
||||||
|
`branch_name` VARCHAR(30) NOT NULL,
|
||||||
|
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) CHARSET=utf8mb4;
|
6
databases/mysql/sql/4_teller_details.sql
Normal file
6
databases/mysql/sql/4_teller_details.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE `teller_details` (
|
||||||
|
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`teller_name` VARCHAR(100) NOT NULL,
|
||||||
|
`branch_name` VARCHAR(30) NOT NULL,
|
||||||
|
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) CHARSET=utf8mb4;
|
@ -1,7 +0,0 @@
|
|||||||
CREATE TABLE `bank_details` (
|
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
|
||||||
`bank_name` VARCHAR(30) DEFAULT '',
|
|
||||||
`country` VARCHAR(30) DEFAULT '',
|
|
||||||
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
|
@ -1,7 +0,0 @@
|
|||||||
CREATE TABLE `branch_details` (
|
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
|
||||||
`branch_name` VARCHAR(30) DEFAULT '',
|
|
||||||
`location` VARCHAR(30) DEFAULT '',
|
|
||||||
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
|
@ -1,7 +0,0 @@
|
|||||||
CREATE TABLE `customer_details` (
|
|
||||||
`id` INT NOT NULL AUTO_INCREMENT,
|
|
||||||
`customer_name` VARCHAR(100) DEFAULT '',
|
|
||||||
`branch_name` VARCHAR(30) DEFAULT '',
|
|
||||||
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
|
@ -1,7 +0,0 @@
|
|||||||
CREATE TABLE `teller_details` (
|
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
|
||||||
`teller_name` varchar(100) DEFAULT '',
|
|
||||||
`branch_name` varchar(30) DEFAULT '',
|
|
||||||
`date_added` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
|
@ -30,7 +30,7 @@ CREATE TABLE `product` (
|
|||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `product_fk0` (`user_id`),
|
KEY `product_fk0` (`user_id`),
|
||||||
CONSTRAINT `product_fk0` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
|
CONSTRAINT `product_fk0` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -55,7 +55,7 @@ CREATE TABLE `user` (
|
|||||||
`email` varchar(255) NOT NULL,
|
`email` varchar(255) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `email` (`email`)
|
UNIQUE KEY `email` (`email`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user