Skip to content
Snippets Groups Projects
Commit d895cd47 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Remove sqlalchemy create_all() call

Let alembic handle the database creation and migration
parent e5655355
No related branches found
No related tags found
No related merge requests found
.PHONY: help build tag push refresh release db initdb test db_image test_image .PHONY: help build tag push refresh release db init_db upgrade_db test db_image test_image
OWNER := registry.esss.lu.se/ics-infrastructure OWNER := registry.esss.lu.se/ics-infrastructure
GIT_TAG := $(shell git describe --always) GIT_TAG := $(shell git describe --always)
...@@ -40,8 +40,12 @@ release: ## build, tag, and push all stacks ...@@ -40,8 +40,12 @@ release: ## build, tag, and push all stacks
db: ## start postgres and redis for development db: ## start postgres and redis for development
docker-compose up -d postgres redis docker-compose up -d postgres redis
initdb: ## initialize the dev database init_db: ## initialize the dev database
docker-compose run --rm web flask initdb docker-compose run --rm web flask db upgrade head
docker-compose run --rm web flask create_defaults
upgrade_db: ## upgrade the dev database
docker-compose run --rm web flask db upgrade head
test: ## run the tests (on current directory) test: ## run the tests (on current directory)
docker-compose run --rm web pytest --cov=app -v docker-compose run --rm web pytest --cov=app -v
......
...@@ -19,9 +19,10 @@ You can use docker for development: ...@@ -19,9 +19,10 @@ You can use docker for development:
or or
$ make db $ make db
# Initialize the database # Initialize the database
$ docker-compose run --rm web flask initdb $ docker-compose run --rm web flask db upgrade head
$ docker-compose run --rm web flask create_defaults
or or
$ make initdb $ make init_db
3. Start the application:: 3. Start the application::
......
...@@ -63,10 +63,8 @@ def sync_users(): ...@@ -63,10 +63,8 @@ def sync_users():
def register_cli(app): def register_cli(app):
@app.cli.command() @app.cli.command()
def initdb(): def create_defaults():
"""Create the database tables and initialize them with default values""" """Create the database default values"""
db.engine.execute('CREATE EXTENSION IF NOT EXISTS citext')
db.create_all()
for instance in defaults: for instance in defaults:
db.session.add(instance) db.session.add(instance)
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment