2015-07-08 17:59:07 +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)
|
|
|
|
|
|
|
|
with db.database.transaction():
|
|
|
|
column = models.User.api_key
|
|
|
|
column.null = True
|
|
|
|
migrate(
|
|
|
|
migrator.add_column('users', 'api_key', models.User.api_key),
|
|
|
|
)
|
|
|
|
|
2016-01-24 09:57:00 +00:00
|
|
|
for user in models.User.select(models.User.id, models.User.api_key):
|
|
|
|
user.save(only=user.dirty_fields)
|
2015-07-08 17:59:07 +00:00
|
|
|
|
|
|
|
migrate(
|
|
|
|
migrator.add_not_null('users', 'api_key')
|
|
|
|
)
|
|
|
|
|
|
|
|
db.close_db(None)
|