2016-09-08 03:21:24 +00:00
|
|
|
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)
|
2016-10-24 09:35:52 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|