def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" op.create_table( 'metrics', # Base, Identifiable, Id sa.Column('id', sa.Integer(), nullable=False), # BisinessObject, Titled, title sa.Column('title', sa.String(length=250), nullable=False), # BusinessObject, Described, description sa.Column('description', sa.Text(), nullable=False), # BusinessObject, Noted, Notes sa.Column('notes', sa.Text(), nullable=False), # BusinessObject, Slugged, Code sa.Column('slug', sa.String(length=250), nullable=False), # BusinessObject, Stateful, State sa.Column('status', sa.String(length=250), nullable=False, server_default="Draft"), # HasObjectState, Review State sa.Column('os_state', sa.String(length=16), nullable=False, server_default="Unreviewed"), # TestPlanned, Assessment Procedure sa.Column('test_plan', sa.Text(), nullable=False), # ObjectPerson, Timeboxed, WithStartDate, Effective Date sa.Column('start_date', sa.Date(), nullable=True), # LastDeprecatedTimeboxed, Last Deprecated Date sa.Column('end_date', sa.Date(), nullable=True), # Commentable, Recipients sa.Column('recipients', sa.String(length=250), nullable=True), # Commentable, Send by default sa.Column('send_by_default', mysql.TINYINT(display_width=1), nullable=True), # Base, ContextRBAC, Context Id sa.Column('context_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('modified_by_id', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8', mysql_engine=u'InnoDB', ) op.create_foreign_key(None, 'metrics', 'contexts', ['context_id'], ['id']) op.create_index('fk_metrics_contexts', 'metrics', ['context_id'], unique=False) op.create_index('ix_metrics_updated_at', 'metrics', ['updated_at'], unique=False) op.create_unique_constraint('uq_metrics', 'metrics', ['slug']) op.create_unique_constraint('uq_t_metrics', 'metrics', ['title']) update_acr.update_models_with_contacts(['Metric'], NON_EDITABLE_ROLES) update_acr.update_ownable_models(['Metric']) acr_propagation.update_acr_propagation_tree(prev_rules.GGRC_PROPAGATION, metric_rules.GGRC_PROPAGATION)
def downgrade(): """Downgrade database schema and/or data back to the previous revision. To downgrade you need first to downgrade ggrc_risks 1) alembic ggrc_risks downgrade -1 """ old_rules = doc_epic_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION new_rules = prev_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION acr_propagation.update_acr_propagation_tree(old_rules, new_rules)
def downgrade(): """Downgrade database schema and/or data back to the previous revision. To downgrade you need first to downgrade 1) alembic ggrc_risks downgrade -1 2) alembic ggrc_basic_permissions downgrade -1 """ allow_to_delete_doc() old_rules = doc_epic_rules.GGRC_PROPAGATION new_rules = prev_rules.GGRC_PROPAGATION acr_propagation.update_acr_propagation_tree(old_rules, new_rules)
def downgrade(): """Downgrade database schema and/or data back to the previous revision.""" op.drop_table('metrics') acr_propagation.update_acr_propagation_tree(metric_rules.GGRC_PROPAGATION, prev_rules.GGRC_PROPAGATION) # Remove items from access_control_list op.execute("DELETE FROM access_control_list " "WHERE object_type = 'Metric'") # Remove items from access_control_roles op.execute("DELETE FROM access_control_roles " "WHERE object_type = 'Metric'")
def downgrade(): """Downgrade database schema and/or data back to the previous revision.""" op.drop_table('metrics') acr_propagation.update_acr_propagation_tree( metric_rules.GGRC_PROPAGATION, prev_rules.GGRC_PROPAGATION ) # Remove items from access_control_list op.execute("DELETE FROM access_control_list " "WHERE object_type = 'Metric'") # Remove items from access_control_roles op.execute("DELETE FROM access_control_roles " "WHERE object_type = 'Metric'")
def run_data_migration(): """Migration runner""" conn = op.get_bind() migrator_id = migrator.get_migration_user_id(conn) data = load_data(conn) update_acr_propagation_tree( acr_propagation_constants.CURRENT_PROPAGATION, new_tree=acr_propagation_constants.WORKFLOW_PROPAGATION ) for tgo in data: create_relationship( conn, tgo.tgo_task_group_id, tgo.tgo_object_id, tgo.tgo_object_type, migrator_id, tgo.tgo_context_id ) create_old_rel_del_revisions(conn, data) remove_old_relationship(conn, data) remove_task_group_objects(conn, data)
def downgrade(): """Downgrade database schema and/or data back to the previous revision.""" from_tree = metric_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION to_tree = prev_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION acr_propagation.update_acr_propagation_tree(from_tree, to_tree)
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" from_tree = prev_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION to_tree = metric_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION acr_propagation.update_acr_propagation_tree(from_tree, to_tree)
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" update_acr_propagation_tree(OLD_CONTROL_PROPAGATION, CONTROL_PROPAGATION)
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" new_tree = update_tree() update_acr_propagation_tree(CURRENT_TREE, new_tree)
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" update_acr_propagation_tree( acr_propagation_constants_workflow_comments.CURRENT_PROPAGATION, new_tree=acr_propagation_constants_workflow_comments.WORKFLOW_PROPAGATION )
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" update_acr_propagation_tree( acr_propagation_constants_workflow_comments.CURRENT_PROPAGATION, new_tree=acr_propagation_constants_workflow_comments. WORKFLOW_PROPAGATION)
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" old_rules = prev_rules.GGRC_PROPAGATION new_rules = doc_epic_rules.GGRC_PROPAGATION acr_propagation.update_acr_propagation_tree(old_rules, new_rules) disallow_to_delete_doc()
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" op.create_table( 'metrics', # Base, Identifiable, Id sa.Column('id', sa.Integer(), nullable=False), # BisinessObject, Titled, title sa.Column('title', sa.String(length=250), nullable=False), # BusinessObject, Described, description sa.Column('description', sa.Text(), nullable=False), # BusinessObject, Noted, Notes sa.Column('notes', sa.Text(), nullable=False), # BusinessObject, Slugged, Code sa.Column('slug', sa.String(length=250), nullable=False), # BusinessObject, Stateful, State sa.Column('status', sa.String(length=250), nullable=False, server_default="Draft"), # HasObjectState, Review State sa.Column('os_state', sa.String(length=16), nullable=False, server_default="Unreviewed"), # TestPlanned, Assessment Procedure sa.Column('test_plan', sa.Text(), nullable=False), # ObjectPerson, Timeboxed, WithStartDate, Effective Date sa.Column('start_date', sa.Date(), nullable=True), # LastDeprecatedTimeboxed, Last Deprecated Date sa.Column('end_date', sa.Date(), nullable=True), # Commentable, Recipients sa.Column('recipients', sa.String(length=250), nullable=True), # Commentable, Send by default sa.Column('send_by_default', mysql.TINYINT(display_width=1), nullable=True), # Base, ContextRBAC, Context Id sa.Column('context_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('modified_by_id', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8', mysql_engine=u'InnoDB', ) op.create_foreign_key( None, 'metrics', 'contexts', ['context_id'], ['id'] ) op.create_index( 'fk_metrics_contexts', 'metrics', ['context_id'], unique=False ) op.create_index( 'ix_metrics_updated_at', 'metrics', ['updated_at'], unique=False ) op.create_unique_constraint( 'uq_metrics', 'metrics', ['slug'] ) op.create_unique_constraint( 'uq_t_metrics', 'metrics', ['title'] ) update_acr.update_models_with_contacts(['Metric'], NON_EDITABLE_ROLES) update_acr.update_ownable_models(['Metric']) acr_propagation.update_acr_propagation_tree( prev_rules.GGRC_PROPAGATION, metric_rules.GGRC_PROPAGATION )
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" old_rules = prev_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION new_rules = doc_epic_evid_comments.GGRC_BASIC_PERMISSIONS_PROPAGATION acr_propagation.update_acr_propagation_tree(old_rules, new_rules)
def downgrade(): """Downgrade database schema and/or data back to the previous revision.""" old_rules = doc_epic_evid_comments.GGRC_BASIC_PERMISSIONS_PROPAGATION new_rules = prev_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION acr_propagation.update_acr_propagation_tree(old_rules, new_rules)
def upgrade(): """Upgrade database schema and/or data, creating a new revision.""" old_rules = prev_rules.GGRC_RISKS_PROPAGATION new_rules = doc_epic_rules.GGRC_RISKS_PROPAGATION acr_propagation.update_acr_propagation_tree(old_rules, new_rules)