Skip to content
Snippets Groups Projects
Commit a13524c8 authored by Vermaat's avatar Vermaat
Browse files

Only create database tables once

If at least our assemblies table exists, we assume the Alembic
migrations will deal with the rest.
parent 7732538c
No related branches found
No related tags found
No related merge requests found
......@@ -173,9 +173,15 @@ def setup_database(alembic_config_path=None, destructive=False):
raise UserError('Cannot find Alembic configuration: %s'
% alembic_config_path)
bind = db.session.get_bind()
if destructive:
db.Base.metadata.drop_all(db.session.get_bind())
db.Base.metadata.create_all(db.session.get_bind())
db.Base.metadata.drop_all(bind)
if destructive or not bind.has_table(Assembly.__tablename__):
# We assume our migrations will take care of everything if at least
# the Assembly table exists.
db.Base.metadata.create_all(bind)
if alembic_config_path:
context = MigrationContext.configure(db.session.connection())
......
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