Compare commits
10 commits
0be34689ec
...
f3e2f8de92
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3e2f8de92 | ||
|
|
4a997ce387 | ||
|
|
59759c4151 | ||
|
|
7f72221586 | ||
|
|
3fa6fe0760 | ||
|
|
d4820eb459 | ||
|
|
04a9e11a67 | ||
|
|
64b1505c86 | ||
|
|
5f891993a8 | ||
|
|
1ebb217897 |
4 changed files with 29 additions and 2 deletions
|
|
@ -1,7 +1,10 @@
|
|||
FROM alpine
|
||||
|
||||
ADD combined_update_ddl.sql /init.sql
|
||||
ADD init.sh /init.sh
|
||||
|
||||
RUN apk add --update --no-cache postgresql-client
|
||||
RUN chmod +x init.sh
|
||||
RUN find . -name "*.sh" | xargs sed -i 's/\r$//'
|
||||
|
||||
CMD [ "sh", "-c", "ls -la && psql --version && psql -U clearing -h db -p 5432 -d clearing -f ./init.sql && tail -f /dev/null" ]
|
||||
ENTRYPOINT [ "./init.sh" ]
|
||||
19
clr_test/db-updater/init.sh
Normal file
19
clr_test/db-updater/init.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
until pg_isready -U clearing -h db -p 5432 -d clearing -t 1; do
|
||||
echo "Waiting for database to be ready..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "PSQL version: $(psql --version)"
|
||||
echo "DB password is $PGPASSWORD"
|
||||
echo "Database connection test:"
|
||||
psql -U clearing -h db -p 5432 -d clearing -c "SELECT 'Database is connected!' AS status"
|
||||
|
||||
echo "Executing SQL file:"
|
||||
cat init.sql
|
||||
|
||||
echo "Updating database"
|
||||
psql -U clearing -h db -p 5432 -d clearing -f init.sql
|
||||
|
||||
tail -f /dev/null
|
||||
|
|
@ -15,6 +15,8 @@ services:
|
|||
|
||||
db-updater:
|
||||
build: db-updater
|
||||
environment:
|
||||
- PGPASSWORD=Aa111111
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
|
|
|||
|
|
@ -117,8 +117,10 @@ def combine_ddl_updates_into_file():
|
|||
logging.info(f"Combining DDLs...")
|
||||
pattern = re.compile(r'updateDDL_(\d+)\.(\d+)\.sql$')
|
||||
|
||||
logging.info(f"Currently found files = {os.listdir(f'{CLR_TEST_DIR}/clearing-all/db')}")
|
||||
|
||||
files = []
|
||||
for filepath in glob(f"{CLR_TEST_DIR}/db/updateDDL_*.sql"):
|
||||
for filepath in glob(f"{CLR_TEST_DIR}/clearing-all/db/updateDDL_*.sql"):
|
||||
filename = os.path.basename(filepath)
|
||||
match = pattern.search(filename)
|
||||
if match:
|
||||
|
|
@ -127,6 +129,7 @@ def combine_ddl_updates_into_file():
|
|||
files.append(((major, minor), filepath))
|
||||
|
||||
files.sort(key=lambda x: x[0])
|
||||
logging.info(f"Found files: {files}")
|
||||
|
||||
with open(f"{CLR_TEST_DIR}/db-updater/combined_update_ddl.sql", 'w', encoding='utf-8') as outfile:
|
||||
for version, filepath in files:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue