Browse Source

simplified migrate.py

tags/9.6-1.1.0
Robin Thoni 6 years ago
parent
commit
23491f0a22
5 changed files with 20 additions and 3 deletions
  1. 4
    0
      Dockerfile
  2. 4
    2
      docker-entrypoint.sh
  3. 3
    0
      migrate-core
  4. 3
    0
      migrate-user
  5. 6
    1
      migrate.py

+ 4
- 0
Dockerfile View File

@@ -27,6 +27,10 @@ COPY ./docker-entrypoint.sh /usr/local/bin/
27 27
 
28 28
 COPY ./migrate.py /usr/local/bin/
29 29
 
30
+COPY ./migrate-core /usr/local/bin/
31
+
32
+COPY ./migrate-user /usr/local/bin/
33
+
30 34
 RUN rm -rf /var/log/*
31 35
 
32 36
 VOLUME "/var/lib/postgresql/backup"

+ 4
- 2
docker-entrypoint.sh View File

@@ -151,12 +151,14 @@ if [ "$1" = 'postgres' ]; then
151 151
                 export PGUSER="postgres"
152 152
                 export PGDATABASE="postgres"
153 153
                 echo "Running core migrate"
154
-                migrate.py --folder /docker-entrypoint-initdb-core.d/ --init
154
+                migrate-core --init
155
+                #migrate.py --folder /docker-entrypoint-initdb-core.d/ --init
155 156
 
156 157
                 #export PGUSER="${POSTGRES_USER}"
157 158
                 export PGDATABASE="${POSTGRES_DB}"
158 159
                 echo "Running user migrate"
159
-                migrate.py --folder /docker-entrypoint-initdb.d/ --init
160
+                migrate-user --init
161
+                #migrate.py --folder /docker-entrypoint-initdb.d/ --init
160 162
 
161 163
 		PGUSER="${PGUSER:-postgres}" \
162 164
 		pg_ctl -D "$PGDATA" -m fast -w stop

+ 3
- 0
migrate-core View File

@@ -0,0 +1,3 @@
1
+#! /usr/bin/env bash
2
+
3
+migrate.py --folder /docker-entrypoint-initdb-core.d/ $* | tee -a /var/lib/postgresql/data/migrate-core.log

+ 3
- 0
migrate-user View File

@@ -0,0 +1,3 @@
1
+#! /usr/bin/env bash
2
+
3
+migrate.py --folder /docker-entrypoint-initdb.d/ $* | tee -a /var/lib/postgresql/data/migrate-user.log

+ 6
- 1
migrate.py View File

@@ -82,7 +82,7 @@ def run_migrations(folder, version_from, version_to, no_run, file_runners):
82 82
         print('Not running because --no-run was specified')
83 83
 
84 84
     if version_from is None:
85
-        print('Initialising from %s (inclusive) to %s (inclusive)' % (versions[0], version_to))
85
+        print('Initializing from %s (inclusive) to %s (inclusive)' % (versions[0], version_to))
86 86
     else:
87 87
         print('Migrating from %s (exclusive) to %s (inclusive)' % (version_from, version_to))
88 88
 
@@ -100,6 +100,11 @@ def run_migrations(folder, version_from, version_to, no_run, file_runners):
100 100
             run_migration(folder, files, version, no_run, file_runners)
101 101
             last_version = version
102 102
 
103
+    if version_from is None:
104
+        print('Initialized from %s (inclusive) to %s (inclusive)' % (versions[0], version_to))
105
+    else:
106
+        print('Migrated from %s (exclusive) to %s (inclusive)' % (version_from, version_to))
107
+
103 108
     return 0
104 109
 
105 110
 def main():

Loading…
Cancel
Save