From a7d46867e15815e569849f8da23ad0937020c1ef Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 21 Nov 2024 13:26:13 +0100 Subject: [PATCH] Add mariadb docker-compose for local dev --- .../integrations/mariadb/docker-compose.yaml | 20 ++++++++++ .../scripts/integrations/mariadb/init.sql | 38 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 packages/server/scripts/integrations/mariadb/docker-compose.yaml create mode 100644 packages/server/scripts/integrations/mariadb/init.sql diff --git a/packages/server/scripts/integrations/mariadb/docker-compose.yaml b/packages/server/scripts/integrations/mariadb/docker-compose.yaml new file mode 100644 index 0000000000..4971b2f5bf --- /dev/null +++ b/packages/server/scripts/integrations/mariadb/docker-compose.yaml @@ -0,0 +1,20 @@ +# Use root/example as user/password credentials +version: "3.1" + +services: + db: + image: mariadb + restart: always + command: --init-file /data/application/init.sql + volumes: + - ./init.sql:/data/application/init.sql + environment: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306:3306 + + adminer: + image: adminer + restart: always + ports: + - 8080:8080 diff --git a/packages/server/scripts/integrations/mariadb/init.sql b/packages/server/scripts/integrations/mariadb/init.sql new file mode 100644 index 0000000000..e687c7c3b1 --- /dev/null +++ b/packages/server/scripts/integrations/mariadb/init.sql @@ -0,0 +1,38 @@ +CREATE DATABASE IF NOT EXISTS main; +USE main; +CREATE TABLE Persons ( + PersonID int NOT NULL AUTO_INCREMENT, + CreatedAt datetime, + Age float DEFAULT 20 NOT NULL, + LastName varchar(255), + FirstName varchar(255), + Address varchar(255), + City varchar(255), + PRIMARY KEY (PersonID) +); +CREATE TABLE Person ( + PersonID int NOT NULL AUTO_INCREMENT, + Name varchar(255), + PRIMARY KEY (PersonID) +); +CREATE TABLE Tasks ( + TaskID int NOT NULL AUTO_INCREMENT, + PersonID INT, + TaskName varchar(255), + CreatedAt DATE, + PRIMARY KEY (TaskID), + CONSTRAINT fkPersons + FOREIGN KEY(PersonID) + REFERENCES Persons(PersonID) +); +CREATE TABLE Products ( + id serial primary key, + name text, + updated time +); +INSERT INTO Persons (FirstName, LastName, Age, Address, City, CreatedAt) VALUES ('Mike', 'Hughes', 28.2, '123 Fake Street', 'Belfast', '2021-01-19 03:14:07'); +INSERT INTO Persons (FirstName, LastName, Age, Address, City, CreatedAt) VALUES ('Dave', 'Johnson', 29, '124 Fake Street', 'Belfast', '2022-04-01 00:11:11'); +INSERT INTO Person (Name) VALUES ('Elf'); +INSERT INTO Tasks (PersonID, TaskName, CreatedAt) VALUES (1, 'assembling', '2020-01-01'); +INSERT INTO Tasks (PersonID, TaskName, CreatedAt) VALUES (2, 'processing', '2019-12-31'); +INSERT INTO Products (name, updated) VALUES ('Meat', '11:00:22'), ('Fruit', '10:00:00');