d1be967e706a_.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. """empty message
  2. Revision ID: d1be967e706a
  3. Revises: 020773f0f9a1
  4. Create Date: 2024-08-27 11:37:10.481634
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = 'd1be967e706a'
  10. down_revision = '020773f0f9a1'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. # ### commands auto generated by Alembic - please adjust! ###
  15. op.create_table('action_card',
  16. sa.Column('id', sa.Integer(), nullable=False),
  17. sa.Column('card_id', sa.Integer(), nullable=True),
  18. sa.Column('action', sa.String(length=500), nullable=True),
  19. sa.Column('img_path', sa.String(length=300), nullable=False),
  20. sa.PrimaryKeyConstraint('id'),
  21. sa.UniqueConstraint('card_id'),
  22. sa.UniqueConstraint('img_path')
  23. )
  24. op.create_table('character_card',
  25. sa.Column('id', sa.Integer(), nullable=False),
  26. sa.Column('card_id', sa.Integer(), nullable=True),
  27. sa.Column('name', sa.String(length=100), nullable=True),
  28. sa.Column('age', sa.Integer(), nullable=True),
  29. sa.Column('role', sa.String(length=100), nullable=True),
  30. sa.Column('interest', sa.String(length=300), nullable=True),
  31. sa.Column('quote', sa.String(length=300), nullable=True),
  32. sa.Column('img_path', sa.String(length=300), nullable=False),
  33. sa.PrimaryKeyConstraint('id'),
  34. sa.UniqueConstraint('card_id'),
  35. sa.UniqueConstraint('img_path')
  36. )
  37. op.create_table('goal_card',
  38. sa.Column('id', sa.Integer(), nullable=False),
  39. sa.Column('card_id', sa.Integer(), nullable=True),
  40. sa.Column('goal', sa.String(length=500), nullable=True),
  41. sa.Column('img_path', sa.String(length=300), nullable=False),
  42. sa.PrimaryKeyConstraint('id'),
  43. sa.UniqueConstraint('card_id'),
  44. sa.UniqueConstraint('img_path')
  45. )
  46. op.create_table('PlayerActionCard',
  47. sa.Column('player', sa.Integer(), nullable=False),
  48. sa.Column('action_card', sa.Integer(), nullable=False),
  49. sa.ForeignKeyConstraint(['action_card'], ['action_card.card_id'], ),
  50. sa.ForeignKeyConstraint(['player'], ['player.id'], ),
  51. sa.PrimaryKeyConstraint('player', 'action_card')
  52. )
  53. with op.batch_alter_table('player', schema=None) as batch_op:
  54. batch_op.add_column(sa.Column('goal_card_id', sa.Integer(), nullable=True))
  55. batch_op.add_column(sa.Column('character_card_id', sa.Integer(), nullable=True))
  56. batch_op.create_foreign_key(None, 'goal_card', ['goal_card_id'], ['card_id'])
  57. batch_op.create_foreign_key(None, 'character_card', ['character_card_id'], ['card_id'])
  58. batch_op.drop_column('goal_card')
  59. batch_op.drop_column('character_card')
  60. # ### end Alembic commands ###
  61. def downgrade():
  62. # ### commands auto generated by Alembic - please adjust! ###
  63. with op.batch_alter_table('player', schema=None) as batch_op:
  64. batch_op.add_column(sa.Column('character_card', sa.INTEGER(), autoincrement=False, nullable=True))
  65. batch_op.add_column(sa.Column('goal_card', sa.INTEGER(), autoincrement=False, nullable=True))
  66. batch_op.drop_constraint(None, type_='foreignkey')
  67. batch_op.drop_constraint(None, type_='foreignkey')
  68. batch_op.drop_column('character_card_id')
  69. batch_op.drop_column('goal_card_id')
  70. op.drop_table('PlayerActionCard')
  71. op.drop_table('goal_card')
  72. op.drop_table('character_card')
  73. op.drop_table('action_card')
  74. # ### end Alembic commands ###