From 5e59d3b43c59de26ad9c7efee22fb893bd1da129 Mon Sep 17 00:00:00 2001 From: aronwk-aaron Date: Tue, 29 Nov 2022 19:23:50 -0600 Subject: [PATCH] fix init db, force play_key_id to be nullable --- .../712d42956a47_initial_migration.py | 3 +- ...f03da7_force_play_key_id_to_be_nullable.py | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 migrations/versions/a6e42ef03da7_force_play_key_id_to_be_nullable.py diff --git a/migrations/versions/712d42956a47_initial_migration.py b/migrations/versions/712d42956a47_initial_migration.py index 0b6edf7..0f72ae5 100644 --- a/migrations/versions/712d42956a47_initial_migration.py +++ b/migrations/versions/712d42956a47_initial_migration.py @@ -103,14 +103,13 @@ def upgrade(): sa.Column('other_player_id', mysql.TEXT(), nullable=False), sa.Column('selection', mysql.TEXT(), nullable=False), sa.Column('submitted', mysql.TIMESTAMP(), server_default=sa.text('now()'), nullable=False), - sa.ForeignKeyConstraint(['resoleved_by_id'], ['accounts.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.add_column('bug_reports', sa.Column('resolved_time', mysql.TIMESTAMP(), nullable=True)) op.add_column('bug_reports', sa.Column('resoleved_by_id', sa.Integer(), nullable=True)) op.add_column('bug_reports', sa.Column('resolution', mysql.TEXT(), nullable=True)) - op.create_foreign_key(None, 'bug_reports', 'accounts', ['resoleved_by_id'], ['id']) + op.create_foreign_key(None, 'bug_reports', 'accounts', ['resoleved_by_id'], ['id'], ondelete='CASCADE') if 'charinfo' not in tables: op.create_table('charinfo', diff --git a/migrations/versions/a6e42ef03da7_force_play_key_id_to_be_nullable.py b/migrations/versions/a6e42ef03da7_force_play_key_id_to_be_nullable.py new file mode 100644 index 0000000..16cca55 --- /dev/null +++ b/migrations/versions/a6e42ef03da7_force_play_key_id_to_be_nullable.py @@ -0,0 +1,33 @@ +"""force play_key_id to be nullable + +Revision ID: a6e42ef03da7 +Revises: 8e52b5c7568a +Create Date: 2022-11-29 19:14:22.645911 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = 'a6e42ef03da7' +down_revision = '8e52b5c7568a' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('accounts', 'play_key_id', + existing_type=mysql.INTEGER(display_width=11), + nullable=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('accounts', 'play_key_id', + existing_type=mysql.INTEGER(display_width=11), + nullable=False) + # ### end Alembic commands ### +