-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug 1321036: verify column attributes (#215). r=bhearsum
- Loading branch information
Showing
7 changed files
with
216 additions
and
25 deletions.
There are no files selected for viewing
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
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,45 @@ | ||
from sqlalchemy import MetaData, Table | ||
|
||
|
||
data_version_nullable_tbls = [ | ||
'permissions_req_signoffs_scheduled_changes_conditions', | ||
'permissions_scheduled_changes', | ||
'permissions_scheduled_changes_conditions', | ||
'product_req_signoffs_scheduled_changes_conditions', | ||
'releases_scheduled_changes', | ||
'releases_scheduled_changes_conditions', | ||
'rules_scheduled_changes', | ||
'rules_scheduled_changes_conditions', | ||
'user_roles' | ||
] | ||
|
||
when_nullable_tbls = [ | ||
'permissions_scheduled_changes_conditions', | ||
'releases_scheduled_changes_conditions' | ||
] | ||
|
||
|
||
def _change_nullable_attr(table_name, column, metadata, nullable): | ||
tbl = Table(table_name, metadata, autoload=True) | ||
|
||
tbl.c[column].alter(nullable=nullable) | ||
|
||
|
||
def upgrade(migrate_engine): | ||
metadata = MetaData(bind=migrate_engine) | ||
|
||
for tbl in data_version_nullable_tbls: | ||
_change_nullable_attr(tbl, 'data_version', metadata, False) | ||
|
||
for tbl in when_nullable_tbls: | ||
_change_nullable_attr(tbl, 'when', metadata, True) | ||
|
||
|
||
def downgrade(migrate_engine): | ||
metadata = MetaData(bind=migrate_engine) | ||
|
||
for tbl in data_version_nullable_tbls: | ||
_change_nullable_attr(tbl, 'data_version', metadata, True) | ||
|
||
for tbl in when_nullable_tbls: | ||
_change_nullable_attr(tbl, 'when', metadata, False) |
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
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
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
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
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