Skip to content

Commit

Permalink
Add Alembic upgrade service
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 13, 2018
1 parent 4d64091 commit 0ede329
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 31 deletions.
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,15 @@ script:
- (cd /tmp/travis/nondockertestgeomapfish/; ./docker-run rm /build/c2ctemplate-cache.json)
- "(cd /tmp/travis/nondockertestgeomapfish/; \
./docker-run make --makefile=empty-vars.mk geoportal/config.yaml)"
- (cd /tmp/travis/nondockertestgeomapfish/; ./docker-run make --makefile=travis.mk alembic.ini)
- (cd /tmp/travis/nondockertestgeomapfish/; ./docker-run alembic --name=main upgrade head)
- (cd /tmp/travis/nondockertestgeomapfish/; ./docker-run alembic --name=static upgrade head)
- (cd /tmp/travis/nondockertestgeomapfish/; ./docker-run alembic --name=static downgrade base)
- (cd /tmp/travis/nondockertestgeomapfish/; ./docker-run alembic --name=main downgrade base)
- (cd /tmp/travis/nondockertestgeomapfish/; ./docker-run make --makefile=travis.mk geoportal/alembic.ini)
- (cd /tmp/travis/nondockertestgeomapfish/; \
./docker-run alembic --config=geoportal/alembic.ini --name=main upgrade head)
- (cd /tmp/travis/nondockertestgeomapfish/; \
./docker-run alembic --config=geoportal/alembic.ini --name=static upgrade head)
- (cd /tmp/travis/nondockertestgeomapfish/; \
./docker-run alembic --config=geoportal/alembic.ini --name=static downgrade base)
- (cd /tmp/travis/nondockertestgeomapfish/; \
./docker-run alembic --config=geoportal/alembic.ini --name=main downgrade base)
## END FOR NON DOCKER TESTS
- ./docker-run make doc

Expand Down
10 changes: 5 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ dockerBuild {
-name \\*.py | xargs travis/squote'''
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-run travis/status.sh)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-run make --makefile=empty-vars.mk geoportal/config.yaml)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-run make --makefile=travis.mk alembic.ini)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-run make --makefile=travis.mk geoportal/alembic.ini)'
try {
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --name=main upgrade head)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --name=static upgrade head)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --name=static downgrade base)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --name=main downgrade base)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --config=geoportal/alembic.ini --name=main upgrade head)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --config=geoportal/alembic.ini --name=static upgrade head)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --config=geoportal/alembic.ini --name=static downgrade base)'
sh '(cd ${HOME}/workspace/testgeomapfish/; ./docker-compose-run alembic --config=geoportal/alembic.ini --name=main downgrade base)'
} catch (Exception error) {
sh '(cd ${HOME}/workspace/testgeomapfish/; docker-compose --file=docker-compose-build.yaml logs)'
throw error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __pycache__/
/project.yaml
/docker-compose.yaml
/docker-compose-build.yaml
/alembic.yaml
/geoportal/alembic.yaml
/testdb/11-schemas.sql
/testdb/12-alembic.sql
/testdb/13-alembic-static.sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ ${service_defaults('tilecloudchain')}\
- /var/sig:/var/sig:ro
${service_defaults('geoportal', 8080)}\

alembic:
image: ${docker_base}-geoportal:${docker_tag}
command:
- alembic
- --name=static
- upgrade
- head
${service_defaults('geoportal', 80)}\

front:
image: haproxy:1.8
volumes_from:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*
!alembic.ini
!alembic.yaml
!config.yaml
!eval_templates.sh
!production.ini
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ __pycache__/
/docker-compose.yaml
/docker-compose-build.yaml
/admin/
/alembic.yaml
/geoportal/alembic.yaml
/testdb/11-schemas.sql
/testdb/12-alembic.sql
/testdb/13-alembic-static.sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ psql -c 'GRANT ALL ON SCHEMA "${schema_static}" TO "${dbuser}";' ${db}
psql -c 'GRANT ALL ON ALL TABLES IN SCHEMA "${schema_static}" TO "${dbuser}";' ${db}
psql -c 'ALTER TABLE main_static.shorturl OWNER TO "www-data";' ${db}

./docker-run make --makefile=$TARGET.mk alembic.ini alembic.yaml
./docker-run make --makefile=$TARGET.mk geoportal/alembic.ini geoportal/alembic.yaml
./docker-run alembic --name=static upgrade head
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ CONF_FILES += $(shell ls -1 apache/*.conf 2> /dev/null) $(CONF_FILES_MAKO:.mako=
DEFAULT_BUILD_RULES ?= docker-build-geoportal \
docker-build-config \
project.yaml \
alembic.ini \
alembic.yaml
geoportal/alembic.ini \
geoportal/alembic.yaml

TILECLOUD_CHAIN ?= TRUE
ifeq ($(TILECLOUD_CHAIN), TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ files_to_move:
to: vars.yaml
version: 2.3
- from: alembic.ini.mako
to: alembic.ini
to: geoportal/alembic.ini
version: 2.3
- from: docker-compose.yml.mako
to: docker-compose.yaml.mako
Expand Down Expand Up @@ -167,3 +167,6 @@ files_to_move:
- from: front/haproxy.cfg
to: front/haproxy.cfg.tmpl
version: 2.3
- from: alembic.ini
to: geoportal/alembic.ini
version: 2.3
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ files_to_move:
to: Makefile
version: 2.3
- from: alembic.ini.mako
to: alembic.ini
to: geoportal/alembic.ini
version: 2.3
- from: docker-compose.yml.mako
to: docker-compose.yaml.mako
Expand Down Expand Up @@ -204,3 +204,6 @@ files_to_move:
- from: front/haproxy.cfg
to: front/haproxy.cfg.tmpl
version: 2.3
- from: alembic.ini
to: geoportal/alembic.ini
version: 2.3
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ WEB_RULE ?= $(DEFAULT_WEB_RULE)
DEFAULT_BUILD_RULES ?= docker-build-geoportal \
docker-build-config \
project.yaml \
alembic.ini \
alembic.yaml \
geoportal/alembic.ini \
geoportal/alembic.yaml \
docker-compose.yaml \
docker-compose-build.yaml

Expand Down Expand Up @@ -393,7 +393,7 @@ checks: flake8 $(CLIENT_CHECK_RULE) git-attributes yamllint spell
git-attributes:
git --no-pager diff --check `git log --oneline | tail -1 | cut --fields=1 --delimiter=' '`

YAML_FILES ?= $(filter-out ./tilegeneration/config.yaml ./geoportal/config.yaml ./alembic.yaml,$(shell find \
YAML_FILES ?= $(filter-out ./tilegeneration/config.yaml ./geoportal/config.yaml ./geoportal/alembic.yaml,$(shell find \
-name .build -prune -or \
-name cgxp -prune -or \
-name node_modules -prune -or \
Expand All @@ -417,7 +417,7 @@ clean: template-clean
$(OUTPUT_DIR)/ \
$(APP_OUTPUT_DIR)/ \
geoportal/$(PACKAGE)_geoportal/locale/$(PACKAGE)-*.pot \
alembic.yaml \
geoportal/alembic.yaml \
.UPGRADE* \
mapcache \
$(addprefix geoportal/$(PACKAGE)_geoportal/locale/, $(addsuffix /LC_MESSAGES/$(PACKAGE)_geoportal-$(L10N_CLIENT_POSTFIX).mo, $(LANGUAGES))) \
Expand Down Expand Up @@ -456,7 +456,7 @@ build-cgxp: $(JSBUILD_OUTPUT_FILES) $(CSS_CGXP_OUTPUT)
lint-ngeo: /build/eslint.timestamp

.PHONY: upgrade-db
upgrade-db: alembic.ini alembic.yaml
upgrade-db: geoportal/alembic.ini geoportal/alembic.yaml
alembic --name=main upgrade head
alembic --name=static upgrade head

Expand Down Expand Up @@ -708,7 +708,7 @@ push-docker:
docker push $(DOCKER_BASE)-geoportal:$(DOCKER_TAG)
docker push $(DOCKER_BASE)-mapserver:$(DOCKER_TAG)

alembic.yaml: $(ALEMBIC_YAML_FILE) vars.yaml CONST_vars.yaml
geoportal/alembic.yaml: $(ALEMBIC_YAML_FILE) vars.yaml CONST_vars.yaml
$(PRERULE_CMD)
c2c-template --vars $< --get-config /build/_alembic.yaml srid schema schema_static sqlalchemy.url cache
mv /build/_alembic.yaml $@
Expand All @@ -721,13 +721,13 @@ testdb/11-schemas.sql: $(ALEMBIC_YAML_FILE) testdb/11-schemas.sql_mako vars.yaml
--files testdb/11-schemas.sql.mako
rm testdb/11-schemas.sql.mako

testdb/12-alembic.sql: alembic.ini alembic.yaml $(shell ls -1 /opt/alembic/main/*.py)
testdb/12-alembic.sql: geoportal/alembic.ini geoportal/alembic.yaml $(shell ls -1 /opt/alembic/main/*.py)
$(PRERULE_CMD)
alembic --name=main upgrade --sql head > $@
alembic --config=$< --name=main upgrade --sql head > $@

testdb/13-alembic-static.sql: alembic.ini alembic.yaml $(shell ls -1 /opt/alembic/static/*.py)
testdb/13-alembic-static.sql: geoportal/alembic.ini geoportal/alembic.yaml $(shell ls -1 /opt/alembic/static/*.py)
$(PRERULE_CMD)
alembic --name=static upgrade --sql head > $@
alembic --config=$< --name=static upgrade --sql head > $@

.PHONY: docker-build-testdb
docker-build-testdb: testdb/11-schemas.sql testdb/12-alembic.sql testdb/13-alembic-static.sql \
Expand Down
4 changes: 2 additions & 2 deletions geoportal/c2cgeoportal_geoportal/scripts/c2cupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ def step11(self, step):
check_call(["make", "--makefile=" + self.options.new_makefile, "build"])

if self.options.nondocker:
command.upgrade(Config("alembic.ini", ini_section="main"), "head")
command.upgrade(Config("alembic.ini", ini_section="static"), "head")
command.upgrade(Config("geoportal/alembic.ini", ini_section="main"), "head")
command.upgrade(Config("geoportal/alembic.ini", ini_section="static"), "head")

args = " --makefile={}".format(self.options.makefile) \
if self.options.makefile != "Makefile" else ""
Expand Down
4 changes: 2 additions & 2 deletions travis/create-new-nondocker-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ sudo a2enmod fcgid
# Minimal build
./docker-run make --makefile=travis.mk \
build \
alembic.ini \
alembic.yaml \
geoportal/alembic.ini \
geoportal/alembic.yaml \
geoportal/production.ini \
geoportal/config.yaml \
docker-compose-build.yaml docker-build-testdb
Expand Down

0 comments on commit 0ede329

Please sign in to comment.