060b20d6d6e6_add_boards.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. """Add boards
  2. Revision ID: 060b20d6d6e6
  3. Revises: d7589827abbb
  4. Create Date: 2020-06-03 09:38:36.189205
  5. """
  6. import datetime
  7. from alembic import op
  8. import sqlalchemy as sa
  9. # revision identifiers, used by Alembic.
  10. revision = '060b20d6d6e6'
  11. down_revision = 'd7589827abbb'
  12. def upgrade():
  13. op.create_table(
  14. 'boards',
  15. sa.Column('id', sa.INTEGER(), nullable=False, autoincrement=True),
  16. sa.Column('project_id', sa.INTEGER(), nullable=False),
  17. sa.Column('tag_id', sa.INTEGER(), nullable=False),
  18. sa.Column('name', sa.String(255), nullable=False),
  19. sa.Column('active', sa.BOOLEAN(), nullable=False, default=True),
  20. sa.Column('created', sa.DateTime(), nullable=False, default=datetime.datetime.utcnow),
  21. sa.Column('date_updated', sa.DateTime(), nullable=False,
  22. default=datetime.datetime.utcnow,
  23. onupdate=datetime.datetime.utcnow),
  24. sa.ForeignKeyConstraint(
  25. ['project_id'],
  26. [u'projects.id'],
  27. name=u'boards_project_id_fkey',
  28. onupdate=u'CASCADE',
  29. ondelete=u'CASCADE'
  30. ),
  31. sa.ForeignKeyConstraint(
  32. ['tag_id'],
  33. [u'tags_colored.id'],
  34. name=u'boards_tag_id_fkey',
  35. onupdate=u'CASCADE'
  36. ),
  37. sa.PrimaryKeyConstraint('id', name=u'boards_pkey'),
  38. sa.UniqueConstraint(
  39. "project_id", "name", name="boards_project_id_name_uix"
  40. ),
  41. )
  42. op.create_table(
  43. 'board_statuses',
  44. sa.Column('id', sa.INTEGER(), nullable=False),
  45. sa.Column('board_id', sa.INTEGER(), nullable=False),
  46. sa.Column('name', sa.String(128), nullable=False),
  47. sa.Column('rank', sa.INTEGER, nullable=False),
  48. sa.Column('default', sa.Boolean, nullable=False, default=False),
  49. sa.Column('bg_color', sa.String(32), nullable=False),
  50. sa.Column('close', sa.BOOLEAN(), nullable=False, default=False),
  51. sa.Column('close_status', sa.Text(), nullable=True),
  52. sa.Column('created', sa.DateTime(), nullable=False, default=datetime.datetime.utcnow),
  53. sa.ForeignKeyConstraint(
  54. ['board_id'],
  55. [u'boards.id'],
  56. name=u'board_statuses_board_id_fkey',
  57. onupdate=u'CASCADE',
  58. ondelete=u'CASCADE'
  59. ),
  60. sa.PrimaryKeyConstraint('id', name=u'board_statuses_pkey'),
  61. sa.UniqueConstraint(
  62. "board_id", "name", name="board_statuses_board_id_name_uix"
  63. ),
  64. )
  65. op.create_table(
  66. 'boards_issues',
  67. sa.Column('issue_uid', sa.String(32), nullable=False),
  68. sa.Column('status_id', sa.INTEGER(), nullable=False),
  69. sa.Column('rank', sa.INTEGER(), nullable=False),
  70. sa.Column('created', sa.DateTime(), nullable=False, default=datetime.datetime.utcnow),
  71. sa.ForeignKeyConstraint(
  72. ['issue_uid'],
  73. [u'issues.uid'],
  74. name=u'boards_issues_issue_uid_fkey',
  75. onupdate=u'CASCADE',
  76. ondelete=u'CASCADE'
  77. ),
  78. sa.ForeignKeyConstraint(
  79. ['status_id'],
  80. [u'board_statuses.id'],
  81. name=u'boards_issues_status_id_fkey',
  82. onupdate=u'CASCADE',
  83. ondelete=u'CASCADE'
  84. ),
  85. sa.PrimaryKeyConstraint('status_id', "issue_uid", name=u'boards_issues_pkey'),
  86. sa.UniqueConstraint(
  87. "status_id", "issue_uid", name="boards_issues_status_id_issue_uid_uix"
  88. ),
  89. )
  90. def downgrade():
  91. """ Remove the tables related to the boards feature. """
  92. op.drop_table('boards_issues')
  93. op.drop_table('board_statuses')
  94. op.drop_table('boards')