From 57d6d82be93a50af40802d130983463f7ae86272 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Thu, 19 Oct 2023 21:53:14 +0200 Subject: [PATCH] ci: add first draft of MySQL data schema --- docker_dev/Dockerfile | 4 ++-- docker_dev/compose.yaml | 13 +++++++--- docker_dev/mysql_schema.sql | 48 +++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/docker_dev/Dockerfile b/docker_dev/Dockerfile index ba72d62..4f96be7 100644 --- a/docker_dev/Dockerfile +++ b/docker_dev/Dockerfile @@ -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) diff --git a/docker_dev/compose.yaml b/docker_dev/compose.yaml index 4ab1353..e1a79b0 100644 --- a/docker_dev/compose.yaml +++ b/docker_dev/compose.yaml @@ -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: {} diff --git a/docker_dev/mysql_schema.sql b/docker_dev/mysql_schema.sql index e69de29..6b954b7 100644 --- a/docker_dev/mysql_schema.sql +++ b/docker_dev/mysql_schema.sql @@ -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! +' +); \ No newline at end of file