redash/old_migrations/0026_add_access_control_tables.py
Arik Fraimovich 70d545410d Add Flask-Migrate to the project
Also moved old migrations to old_migrations folder (before deleting them entirely).
2016-12-07 17:59:01 +02:00

23 lines
684 B
Python

from redash.models import db, Change, AccessPermission, Query, Dashboard
from playhouse.migrate import PostgresqlMigrator, migrate
if __name__ == '__main__':
if not Change.table_exists():
Change.create_table()
if not AccessPermission.table_exists():
AccessPermission.create_table()
migrator = PostgresqlMigrator(db.database)
try:
migrate(
migrator.add_column('queries', 'version', Query.version),
migrator.add_column('dashboards', 'version', Dashboard.version)
)
except Exception as ex:
print "Error while adding version column to queries/dashboards. Maybe it already exists?"
print ex