feat(DevWeb): Support multiple databases (test, prod)

This commit is contained in:
Lucàs
2024-03-22 17:43:46 +01:00
parent 8e9bfebffe
commit db7750d5aa
9 changed files with 83 additions and 34 deletions
+1
View File
@@ -0,0 +1 @@
init/
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
databases=("db_test" "db_prod")
template="template.sql"
output="init/init.sql"
> "$output"
for database in "${databases[@]}"; do
sed "s/\${database}/$database/g" "$template" >> "$output"
echo "" >> "$output"
done
@@ -1,5 +1,5 @@
CREATE DATABASE IF NOT EXISTS db;
USE db;
CREATE DATABASE IF NOT EXISTS ${database};
USE ${database};
-- Table: User
CREATE TABLE IF NOT EXISTS `user`
@@ -55,8 +55,8 @@ CREATE TABLE IF NOT EXISTS recovery_password_token
FOREIGN KEY (user_id) REFERENCES `user` (id)
);
DELIMITER //
CREATE TRIGGER expires_at BEFORE INSERT ON recovery_password_token FOR EACH ROW
BEGIN
SET NEW.`expires_at` = TIMESTAMPADD(MINUTE, 15, CURRENT_TIMESTAMP);
END;//
# DELIMITER //
# CREATE TRIGGER expires_at BEFORE INSERT ON recovery_password_token FOR EACH ROW
# BEGIN
# SET NEW.`expires_at` = TIMESTAMPADD(MINUTE, 15, CURRENT_TIMESTAMP);
# END;//