add more db inits

This commit is contained in:
2021-08-18 00:01:56 -05:00
parent bc3f010a5a
commit 372c1ad35d
5 changed files with 93 additions and 10 deletions

2
.gitignore vendored
View File

@@ -1 +1,3 @@
/target /target
Cargo.lock
*.log

27
db/mariadb/init.sql Normal file
View File

@@ -0,0 +1,27 @@
CREATE DATABASE demo;
USE demo;
-- a single table is used for all events in the cqrs system
CREATE TABLE events
(
aggregate_type VARCHAR(256) NOT NULL,
aggregate_id VARCHAR(256) NOT NULL,
sequence bigint CHECK (sequence >= 0) ,
payload TEXT ,
metadata TEXT ,
timestamp timestamp DEFAULT (CURRENT_TIMESTAMP),
PRIMARY KEY (aggregate_type, aggregate_id, sequence)
);
CREATE
USER
'demo_user'@'localhost'
IDENTIFIED BY
'password';
GRANT
ALL
ON
demo.*
TO
'demo_user'@'localhost';

27
db/mysql/init.sql Normal file
View File

@@ -0,0 +1,27 @@
CREATE DATABASE demo;
USE demo;
-- a single table is used for all events in the cqrs system
CREATE TABLE events
(
aggregate_type VARCHAR(256) NOT NULL,
aggregate_id VARCHAR(256) NOT NULL,
sequence bigint CHECK (sequence >= 0) NOT NULL,
payload TEXT NOT NULL,
metadata TEXT NOT NULL,
timestamp timestamp DEFAULT (CURRENT_TIMESTAMP),
PRIMARY KEY (aggregate_type, aggregate_id, sequence)
);
CREATE
USER
'demo_user'@'localhost'
IDENTIFIED BY
'password';
GRANT
ALL
ON
demo.*
TO
'demo_user'@'localhost';

View File

@@ -1,3 +1,6 @@
CREATE DATABASE demo;
\c demo;
-- a single table is used for all events in the cqrs system -- a single table is used for all events in the cqrs system
CREATE TABLE events CREATE TABLE events
( (
@@ -21,8 +24,6 @@ ENCRYPTED PASSWORD
GRANT GRANT
ALL PRIVILEGES ALL PRIVILEGES
ON TABLE ON TABLE
events, events
snapshots,
queries
TO TO
demo_user; demo_user;

View File

@@ -1,16 +1,41 @@
version: "3.4" version: "3.4"
services: services:
db: maria-db:
image: postgres image: mariadb
volumes: volumes:
- "./db:/docker-entrypoint-initdb.d" - "./db/mariadb:/docker-entrypoint-initdb.d"
networks: networks:
- default - default
ports: ports:
- "5433:5432" - "8084:3306"
environment:
#- "MARIADB_USER=root"
- "MARIADB_ROOT_PASSWORD=admin_pass"
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
mysql-db:
image: mysql
volumes:
- "./db/mysql:/docker-entrypoint-initdb.d"
networks:
- default
ports:
- "8086:3306"
environment:
#- "MYSQL_USER=root"
- "MYSQL_ROOT_PASSWORD=admin_pass"
command: --default-authentication-plugin=mysql_native_password
postgres-db:
image: postgres
volumes:
- "./db/postgres:/docker-entrypoint-initdb.d"
networks:
- default
ports:
- "8087:5432"
environment: environment:
- "POSTGRES_DB=demo"
- "POSTGRES_USER=admin" - "POSTGRES_USER=admin"
- "POSTGRES_PASSWORD=admin_pass" - "POSTGRES_PASSWORD=admin_pass"
@@ -20,6 +45,7 @@ services:
networks: networks:
- default - default
ports: ports:
- "8081:8080" - "8083:8080"
depends_on: depends_on:
- db - mysql-db
- postgres-db