Migratino to set Widget.type and Widget.query_id to nullables

This commit is contained in:
Arik Fraimovich 2014-02-09 14:33:05 +02:00
parent 704f2c176d
commit 93fe613a9a
2 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,13 @@
from playhouse.migrate import Migrator
from redash import db
from redash import models
if __name__ == '__main__':
db.connect_db()
migrator = Migrator(db.database)
with db.database.transaction():
migrator.set_nullable(models.Widget, models.Widget.query_id, True)
migrator.set_nullable(models.Widget, models.Widget.type, True)
db.close_db(None)

View File

@ -212,12 +212,16 @@ class Visualization(BaseModel):
class Widget(db.Model):
id = peewee.PrimaryKeyField()
visualization = peewee.ForeignKeyField(Visualization, related_name='widgets')
type = peewee.CharField(max_length=100, null=True) # unused; kept for backward compatability
width = peewee.IntegerField()
options = peewee.TextField()
dashboard = peewee.ForeignKeyField(Dashboard, related_name='widgets', index=True)
created_at = peewee.DateTimeField(default=datetime.datetime.now)
# unused; kept for backward compatability:
type = peewee.CharField(max_length=100, null=True)
query_id = peewee.IntegerField(null=True)
class Meta:
db_table = 'widgets'