Skip to content

Commit b2880f4

Browse files
authored
Release v1.3.1 (#112)
1 parent 65c601c commit b2880f4

File tree

9 files changed

+184
-23
lines changed

9 files changed

+184
-23
lines changed

alembic_fix

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
CONTAINER=$(docker ps -f name=graphql-postgres --format {{.Names}})
4+
if [ -z $CONTAINER ]; then
5+
echo "Could not find a running container for the database."
6+
exit 1
7+
fi
8+
9+
10+
TABLE_EXISTS=$(docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'alembic_version';" -qtAX)
11+
if [ $TABLE_EXISTS -eq 0 ]
12+
then
13+
echo "Table alembic_version does not exist. Creating..."
14+
docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL, PRIMARY KEY (version_num))" -qtAX
15+
echo "Table created."
16+
else
17+
return 0
18+
fi
19+
20+
21+
echo "Checking revision..."
22+
if [ $(docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM information_schema.columns WHERE table_name='attribute' and column_name='source_code';" -qtAX) -ne 0 ]
23+
then
24+
echo "Set revision to 87f463aa5112"
25+
docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "INSERT INTO alembic_version VALUES('87f463aa5112')" -qtAX
26+
elif [ $(docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'labeling_access_link';" -qtAX) -ne 0 ]
27+
then
28+
echo "Set revision to 9618924f9679"
29+
docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "INSERT INTO alembic_version VALUES('9618924f9679')" -qtAX
30+
elif [ $(docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'app_version';" -qtAX) -ne 0 ]
31+
then
32+
echo "Set revision to 5b3a4deea1c4"
33+
docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "INSERT INTO alembic_version VALUES('5b3a4deea1c4')" -qtAX
34+
elif [ $(docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'organization';" -qtAX) -ne 0 ]
35+
then
36+
echo "Set revision to 992352f4c1f9"
37+
docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "INSERT INTO alembic_version VALUES('992352f4c1f9')" -qtAX
38+
else
39+
echo "Nothing found assuming inital db"
40+
docker exec $CONTAINER psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "DROP TABLE alembic_version" -qtAX
41+
fi

alembic_fix.bat

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
@echo off
2+
3+
SET name=initial
4+
FOR /F "tokens=*" %%g IN ('"docker ps -f name=graphql-postgres --format {{.Names}}"') do (SET name=%%g)
5+
6+
IF "%name%" == "initial" (
7+
echo cant find name
8+
goto :eof
9+
)
10+
11+
FOR /F "tokens=*" %%g IN ('docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'alembic_version';" -qtAX') do (SET result=%%g)
12+
13+
IF "%result%" == "0" (
14+
echo creating table
15+
docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL, PRIMARY KEY (version_num))" -qtAX
16+
echo table created
17+
) ELSE (
18+
goto :eof
19+
)
20+
21+
goto VERSION_87f463aa5112
22+
23+
24+
25+
:END
26+
27+
goto :eof
28+
29+
:VERSION_87f463aa5112
30+
31+
echo checking version 87f463aa5112
32+
33+
FOR /F "tokens=*" %%g IN ('docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM information_schema.columns WHERE table_name='attribute' and column_name='source_code';" -qtAX') do (SET result=%%g)
34+
35+
IF "%result%" == "0" (
36+
goto VERSION_9618924f9679
37+
) ELSE (
38+
Call :setVersion 87f463aa5112
39+
goto END
40+
)
41+
42+
:VERSION_9618924f9679
43+
echo checking version 9618924f9679
44+
FOR /F "tokens=*" %%g IN ('docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'labeling_access_link';" -qtAX') do (SET result=%%g)
45+
46+
IF "%result%" == "0" (
47+
goto VERSION_5b3a4deea1c4
48+
) ELSE (
49+
Call :setVersion 9618924f9679
50+
goto END
51+
)
52+
53+
:VERSION_5b3a4deea1c4
54+
echo checking version 5b3a4deea1c4
55+
FOR /F "tokens=*" %%g IN ('docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'app_version';" -qtAX') do (SET result=%%g)
56+
57+
IF "%result%" == "0" (
58+
goto VERSION_992352f4c1f9
59+
) ELSE (
60+
Call :setVersion 5b3a4deea1c4
61+
goto END
62+
)
63+
64+
:VERSION_992352f4c1f9
65+
echo checking version 992352f4c1f9
66+
FOR /F "tokens=*" %%g IN ('docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename = 'organization';" -qtAX') do (SET result=%%g)
67+
68+
IF "%result%" == "0" (
69+
goto NO_VERSION
70+
) ELSE (
71+
Call :setVersion 992352f4c1f9
72+
goto END
73+
)
74+
75+
:NO_VERSION
76+
echo nothing found assuming inital db
77+
docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "DROP TABLE alembic_version" -qtAX
78+
goto END
79+
80+
81+
:setVersion
82+
Set "version=%~1"
83+
84+
FOR /F "tokens=*" %%g IN ('docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "SELECT COUNT(*) FROM alembic_version;" -qtAX') do (SET result=%%g)
85+
86+
IF "%result%" == "0" (
87+
echo setting version to %version%
88+
docker exec %name% psql -d postgresql://postgres:onetask@graphql-postgres:5432 -c "INSERT INTO alembic_version VALUES('%version%')" -qtAX
89+
echo version is %version%
90+
)
91+
92+
93+
94+
EXIT /B 0

start

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/bin/bash
22

3-
echo "We are currently experiencing some issues with refinery."
4-
echo "We are working on it. Sorry, for the inconvenience."
5-
echo "If you pull the repository and this message is still there, please try to pull it at a later time."
6-
exit 1
7-
83
LOCAL_VOLUME_POSTGRES=./postgres-data
94
LOCAL_VOLUME_MINIO=./minio-data
105
LOCAL_VOLUME_QDRANT=./qdrant-storage
@@ -49,6 +44,9 @@ if [ ! -f "./refinery/oathkeeper/jwks.json" ]; then
4944
docker run --rm docker.io/oryd/oathkeeper:v0.38 credentials generate --alg RS256 > refinery/oathkeeper/jwks.json
5045
fi
5146

47+
source wait_until_db_ready
48+
source alembic_fix
49+
5250
docker-compose -f refinery/docker-compose.yml up -d
5351

5452
echo "UI: http://localhost:4455/app/"

start.bat

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
@echo off
22
setlocal enabledelayedexpansion
33

4-
echo "We are currently experiencing some issues with refinery."
5-
echo "We are working on it. Sorry, for the inconvenience."
6-
echo "If you pull the repository and this message is still there, please try to pull it at a later time."
7-
exit 1
8-
94
set LOCAL_VOLUME_POSTGRES=".\postgres-data"
105
set LOCAL_VOLUME_MINIO=".\minio-data"
116
set LOCAL_VOLUME_QDRANT=".\qdrant-storage"
@@ -68,6 +63,8 @@ IF NOT EXIST .\refinery\oathkeeper\jwks.json (
6863
docker run --rm docker.io/oryd/oathkeeper:v0.38 credentials generate --alg RS256 > refinery\oathkeeper\jwks.json
6964
)
7065

66+
call wait_until_db_ready.bat
67+
call alembic_fix.bat
7168

7269
docker-compose -f refinery\docker-compose.yml up -d
7370

stop.bat

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
@echo off
22

3-
echo "We are currently experiencing some issues with refinery."
4-
echo "We are working on it. Sorry, for the inconvenience."
5-
echo "If you pull the repository and this message is still there, please try to pull it at a later time."
6-
exit 1
73

84
docker-compose -f refinery\docker-compose.yml down --remove-orphans
95
if "%1" neq "update" pause

update

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/bin/bash
22

3-
echo "We are currently experiencing some issues with refinery."
4-
echo "We are working on it. Sorry, for the inconvenience."
5-
echo "If you pull the repository and this message is still there, please try to pull it at a later time."
6-
exit 1
7-
83
echo "Checking refinery installation..."
94
if test -f "./refinery/docker-compose.yml"; then
105
echo "Refinery is installed."

update.bat

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
@echo off
22
setlocal enabledelayedexpansion
33

4-
echo "We are currently experiencing some issues with refinery."
5-
echo "We are working on it. Sorry, for the inconvenience."
6-
echo "If you pull the repository and this message is still there, please try to pull it at a later time."
7-
exit 1
84

95
echo Checking refinery installation...
106
if exist "%~dp0\refinery\docker-compose.yml" (

wait_until_db_ready

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
echo "Starting db..."
3+
4+
docker-compose -f refinery/docker-compose.yml up -d graphql-postgres
5+
6+
CONTAINER=$(docker ps -f name=graphql-postgres --format {{.Names}})
7+
if [ -z $CONTAINER ]; then
8+
echo "Could not find a running container for the database."
9+
exit 1
10+
fi
11+
12+
echo "Waiting for container to be ready..."
13+
docker exec $CONTAINER pg_isready > /dev/null 2>&1
14+
while [ $? -ne 0 ]
15+
do
16+
docker exec $CONTAINER pg_isready > /dev/null 2>&1
17+
done
18+
19+
echo "db ready"

wait_until_db_ready.bat

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@echo off
2+
3+
echo starting db...
4+
5+
docker-compose -f refinery\docker-compose.yml up -d graphql-postgres
6+
7+
SET name=initial
8+
FOR /F "tokens=*" %%g IN ('"docker ps -f name=graphql-postgres --format {{.Names}}"') do (SET name=%%g)
9+
10+
IF "%name%" == "initial" (
11+
echo cant find name
12+
goto :eof
13+
)
14+
15+
echo waiting for pg_isready...
16+
17+
:RECHECK
18+
docker exec %name% pg_isready > nul
19+
IF %ERRORLEVEL% NEQ 0 (
20+
timeout 1 > nul
21+
goto RECHECK
22+
)
23+
24+
echo db ready.
25+

0 commit comments

Comments
 (0)