fix: migrate and gen_migrations should work
This commit is contained in:
parent
68cd9c5bb4
commit
ee6390d723
@ -1 +1 @@
|
|||||||
Subproject commit 2d996399411565af57e30ca2d2082764bd1ed9e1
|
Subproject commit 3b3eae9b02e25ae9077d5f5e0c63cf694b896e58
|
@ -2,7 +2,7 @@ create schema human_uuid;
|
|||||||
|
|
||||||
select public.create_newtype_text('human_uuid.huid');
|
select public.create_newtype_text('human_uuid.huid');
|
||||||
|
|
||||||
create table human_uuid.used (huid text primary key);
|
create table human_uuid.used (human_uuid.huid text primary key);
|
||||||
create table human_uuid.object
|
create table human_uuid.object
|
||||||
( id int primary key generated always as identity
|
( id int primary key generated always as identity
|
||||||
, word text unique
|
, word text unique
|
||||||
|
@ -8,6 +8,17 @@ source ./scripts/env.sh ./.env.schema
|
|||||||
base_or_head="$1"
|
base_or_head="$1"
|
||||||
rev="$2"
|
rev="$2"
|
||||||
|
|
||||||
|
if [[ -n "$base_or_head" ]]; then
|
||||||
|
docker compose kill "$base_or_head"
|
||||||
|
docker compose rm -vf "$base_or_head"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$base_or_head" = "base" ]]; then
|
||||||
|
port=5432
|
||||||
|
else
|
||||||
|
port=5433
|
||||||
|
fi
|
||||||
|
|
||||||
db() {
|
db() {
|
||||||
echo -n "postgresql:///$1?port=$port&user=$POSTGRES_USER&password=$POSTGRES_PASSWORD"
|
echo -n "postgresql:///$1?port=$port&user=$POSTGRES_USER&password=$POSTGRES_PASSWORD"
|
||||||
}
|
}
|
||||||
@ -19,17 +30,6 @@ initdb() {
|
|||||||
psql --quiet $(db postgres) -c "create database dnim"
|
psql --quiet $(db postgres) -c "create database dnim"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -n "$base_or_head" ]]; then
|
|
||||||
docker compose kill "$base_or_head"
|
|
||||||
docker compose rm -vf "$base_or_head"
|
|
||||||
|
|
||||||
if [[ "$base_or_head" = "head" ]]; then
|
|
||||||
port=5433
|
|
||||||
else
|
|
||||||
port=5432
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$rev" = "empty" ]]; then
|
if [[ "$rev" = "empty" ]]; then
|
||||||
docker compose up --wait --wait-timeout 30 -d "$base_or_head"
|
docker compose up --wait --wait-timeout 30 -d "$base_or_head"
|
||||||
initdb
|
initdb
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
set -e
|
set -xe
|
||||||
|
|
||||||
source ./scripts/env.sh ./.env.schema
|
source ./scripts/env.sh ./.env.schema
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ fi;
|
|||||||
migration="./migrations/${base}_to_${head}.sql"
|
migration="./migrations/${base}_to_${head}.sql"
|
||||||
|
|
||||||
db() {
|
db() {
|
||||||
echo -n "postgresql:///dnim?port=$1&user=$POSTGRES_USER&password=$POSTGRES_PASSWORD"
|
echo -n "postgresql+pg8000:///dnim?port=$1&user=$POSTGRES_USER&password=$POSTGRES_PASSWORD"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "$base" ]] || [[ -z "$head" ]]; then
|
if [[ -z "$base" ]] || [[ -z "$head" ]]; then
|
||||||
@ -23,9 +23,11 @@ if [[ -z "$base" ]] || [[ -z "$head" ]]; then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
schema_changed=$(git diff --quiet "$base" "$head" -- ./schema)
|
schema_changed=$(git diff --quiet "$base" "$head" -- ./schema)
|
||||||
schema_changed_exit=$?
|
schema_changed_exit=$?
|
||||||
if [[ $schema_changed_exit="1" ]]; then
|
set -e
|
||||||
|
if [[ "$schema_changed_exit" = "0" ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
exit 0;
|
exit 0;
|
||||||
fi;
|
fi;
|
||||||
|
Loading…
Reference in New Issue
Block a user