2016-01-24 09:57:00 +00:00
|
|
|
import peewee
|
2015-10-30 05:01:21 +00:00
|
|
|
from playhouse.migrate import PostgresqlMigrator, migrate
|
|
|
|
|
|
|
|
from redash.models import db
|
|
|
|
from redash import models
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
db.connect_db()
|
|
|
|
migrator = PostgresqlMigrator(db.database)
|
|
|
|
|
2016-01-24 09:57:00 +00:00
|
|
|
cursor = db.database.execute_sql("SELECT column_name FROM information_schema.columns WHERE table_name='alerts' and column_name='rearm';")
|
|
|
|
if cursor.rowcount > 0:
|
|
|
|
print "Column exists. Skipping."
|
|
|
|
exit()
|
|
|
|
|
2015-10-30 05:01:21 +00:00
|
|
|
with db.database.transaction():
|
|
|
|
migrate(
|
2015-12-14 08:47:46 +00:00
|
|
|
migrator.add_column('alerts', 'rearm', models.Alert.rearm),
|
2015-10-30 05:01:21 +00:00
|
|
|
)
|
2016-01-24 09:57:00 +00:00
|
|
|
|
2015-10-30 05:01:21 +00:00
|
|
|
db.close_db(None)
|