-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sqllab] db migration - setting Database.allow_run_sync=True (#1174)
- Loading branch information
1 parent
1fa1892
commit 8cb0bea
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
caravel/migrations/versions/eca4694defa7_sqllab_setting_defaults.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""sqllab_setting_defaults | ||
Revision ID: eca4694defa7 | ||
Revises: 5e4a03ef0bf0 | ||
Create Date: 2016-09-22 11:31:50.543820 | ||
""" | ||
from alembic import op | ||
from caravel import db | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy import (Column, Integer, Boolean) | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'eca4694defa7' | ||
down_revision = '5e4a03ef0bf0' | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class Database(Base): | ||
|
||
"""An ORM object that stores Database related information""" | ||
|
||
__tablename__ = 'dbs' | ||
id = Column(Integer, primary_key=True) | ||
allow_run_sync = Column(Boolean, default=True) | ||
|
||
|
||
def upgrade(): | ||
bind = op.get_bind() | ||
session = db.Session(bind=bind) | ||
|
||
for obj in session.query(Database).all(): | ||
obj.allow_run_sync = True | ||
|
||
session.commit() | ||
session.close() | ||
|
||
|
||
def downgrade(): | ||
pass |