ci: add first draft of MySQL data schema

This commit is contained in:
David Bailey 2023-10-19 21:53:14 +02:00
parent 1862ccbbb6
commit 57d6d82be9
3 changed files with 60 additions and 5 deletions

View file

@ -1,7 +1,7 @@
FROM composer
WORKDIR /app
COPY composer.* .
COPY www/composer.* .
RUN composer install
FROM php:apache
@ -14,5 +14,5 @@ RUN a2enmod rewrite
RUN a2enmod headers
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
COPY . .
COPY www/ .
RUN chmod -R a+r $(ls -I vendor)

View file

@ -9,11 +9,12 @@ services:
watch:
- path: ./
action: rebuild
- path: ../.
- path: ../www/
action: sync
target: /var/www/html
ignore:
- ../.git
- mysql_schema.sql
mysql:
build:
dockerfile: MysqlDockerfile
@ -23,7 +24,13 @@ services:
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
- sqlvolume:/var/lib/mysql
ports:
- 3306:3306
develop:
watch:
- path: mysql_schema.sql
action: rebuild
# volumes:
# - sqlvolume:/var/lib/mysql
volumes:
sqlvolume: {}

View file

@ -0,0 +1,48 @@
CREATE DATABASE dragon_fire;
USE dragon_fire;
CREATE TABLE posts (
post_id INTEGER AUTO_INCREMENT,
post_path VARCHAR(255) NOT NULL,
post_path_depth INTEGER NOT NULL DEFAULT 0,
post_title TEXT,
post_description TEXT,
post_brief TEXT,
post_content MEDIUMTEXT,
post_content_type TEXT,
PRIMARY KEY(post_id),
CONSTRAINT unique_post_path UNIQUE (post_path),
INDEX(post_path),
INDEX(post_path_depth, post_path)
);
CREATE TABLE post_tags (
post_id INTEGER,
tag VARCHAR(255),
CONSTRAINT post_fkey
FOREIGN KEY(post_id) REFERENCES posts(post_id)
ON DELETE CASCADE,
INDEX(post_id),
INDEX(tag)
);
INSERT INTO posts (post_path, post_title, post_content)
VALUES (
'/about',
'About the Dergs',
'
# About the dergs indeed
This is just a simple test. Might be nice, though!
'
);