mirror of
https://github.com/OHTU-German-learning-website/OHTU-German-learning-website.git
synced 2026-10-12 19:13:51 +03:00
do pgmigrate in docker (#131)
This commit is contained in:
+6
-1
@@ -11,5 +11,10 @@ echo "Migrating done"
|
||||
# We generate the schema file to make sure that the schema is up to date
|
||||
# The github workflow will check for uncommitted changes and fail if there is
|
||||
# a difference between the schema file and the actual schema in the database
|
||||
pgmigrate dump -d postgres://ohtu:password@localhost:7742/gradesa --out schema.sql
|
||||
|
||||
# Create a temporary schema file inside the container
|
||||
docker exec gradesa-db sh -c "pgmigrate dump -d postgres://ohtu:password@localhost:5432/gradesa --out /tmp/schema.sql"
|
||||
|
||||
# Copy the schema file from the container to the local directory
|
||||
docker cp gradesa-db:/tmp/schema.sql ./schema.sql
|
||||
echo "Dumping done"
|
||||
|
||||
Executable → Regular
-8
@@ -43,8 +43,6 @@ CREATE TABLE public.forms (
|
||||
description_de text
|
||||
);
|
||||
|
||||
CREATE TRIGGER updated_at BEFORE UPDATE ON public.forms FOR EACH ROW EXECUTE FUNCTION updated_at();
|
||||
|
||||
ALTER TABLE public.form_parts
|
||||
ADD CONSTRAINT form_parts_form_id_fkey
|
||||
FOREIGN KEY (form_id) REFERENCES forms(id) ON DELETE RESTRICT;
|
||||
@@ -58,8 +56,6 @@ CREATE TABLE public.part_questions (
|
||||
title_de text
|
||||
);
|
||||
|
||||
CREATE TRIGGER updated_at BEFORE UPDATE ON public.part_questions FOR EACH ROW EXECUTE FUNCTION updated_at();
|
||||
|
||||
ALTER TABLE public.part_questions
|
||||
ADD CONSTRAINT part_questions_form_part_id_fkey
|
||||
FOREIGN KEY (form_part_id) REFERENCES form_parts(id) ON DELETE RESTRICT;
|
||||
@@ -84,8 +80,6 @@ ALTER TABLE public.user_question_answers
|
||||
ADD CONSTRAINT user_question_answers_user_id_part_question_id_key
|
||||
UNIQUE (user_id, part_question_id);
|
||||
|
||||
CREATE TRIGGER updated_at BEFORE UPDATE ON public.user_question_answers FOR EACH ROW EXECUTE FUNCTION updated_at();
|
||||
|
||||
ALTER TABLE public.user_question_answers
|
||||
ADD CONSTRAINT user_question_answers_part_question_id_fkey
|
||||
FOREIGN KEY (part_question_id) REFERENCES part_questions(id) ON DELETE RESTRICT;
|
||||
@@ -99,8 +93,6 @@ CREATE TABLE public.users (
|
||||
salt text NOT NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER updated_at BEFORE UPDATE ON public.users FOR EACH ROW EXECUTE FUNCTION updated_at();
|
||||
|
||||
ALTER TABLE public.user_question_answers
|
||||
ADD CONSTRAINT user_question_answers_user_id_fkey
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
|
||||
|
||||
@@ -15,6 +15,12 @@ services:
|
||||
test: ["CMD", "pg_isready", "-U", "postgres"]
|
||||
interval: 10s
|
||||
retries: 20
|
||||
command: >
|
||||
sh -c "apt update &&
|
||||
apt install -y wget &&
|
||||
wget https://github.com/peterldowns/pgmigrate/releases/download/v0.0.6%2Bcommit.4f90829/pgmigrate-linux-amd64 -O /usr/local/bin/pgmigrate &&
|
||||
chmod +x /usr/local/bin/pgmigrate &&
|
||||
/usr/local/bin/docker-entrypoint.sh postgres"
|
||||
pgtestdb:
|
||||
image: postgres:15
|
||||
container_name: gradesa-pgtestdb
|
||||
|
||||
Reference in New Issue
Block a user