201705041144_933bd7d807c4_add_more_non_nullables.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. """Add more non nullables
  2. Revision ID: 933bd7d807c4
  3. Revises: d87cea4e995d
  4. Create Date: 2017-05-04 11:44:16.146471
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. import flaskbb
  9. # revision identifiers, used by Alembic.
  10. revision = '933bd7d807c4'
  11. down_revision = 'd87cea4e995d'
  12. branch_labels = ()
  13. depends_on = None
  14. def upgrade():
  15. # ### commands auto generated by Alembic - please adjust! ###
  16. with op.batch_alter_table('conversations', schema=None) as batch_op:
  17. batch_op.alter_column('date_created',
  18. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  19. nullable=False)
  20. with op.batch_alter_table('forumsread', schema=None) as batch_op:
  21. batch_op.alter_column('last_read',
  22. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  23. nullable=False)
  24. with op.batch_alter_table('groups_users', schema=None) as batch_op:
  25. batch_op.alter_column('group_id',
  26. existing_type=sa.INTEGER(),
  27. nullable=False)
  28. batch_op.alter_column('user_id',
  29. existing_type=sa.INTEGER(),
  30. nullable=False)
  31. with op.batch_alter_table('messages', schema=None) as batch_op:
  32. batch_op.alter_column('date_created',
  33. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  34. nullable=False)
  35. with op.batch_alter_table('posts', schema=None) as batch_op:
  36. batch_op.alter_column('date_created',
  37. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  38. nullable=False)
  39. with op.batch_alter_table('reports', schema=None) as batch_op:
  40. batch_op.alter_column('post_id',
  41. existing_type=sa.INTEGER(),
  42. nullable=True)
  43. batch_op.alter_column('reported',
  44. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  45. nullable=False)
  46. batch_op.alter_column('reporter_id',
  47. existing_type=sa.INTEGER(),
  48. nullable=True)
  49. with op.batch_alter_table('topics', schema=None) as batch_op:
  50. batch_op.alter_column('date_created',
  51. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  52. nullable=False)
  53. batch_op.alter_column('important',
  54. existing_type=sa.BOOLEAN(),
  55. nullable=False)
  56. batch_op.alter_column('last_updated',
  57. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  58. nullable=False)
  59. batch_op.alter_column('locked',
  60. existing_type=sa.BOOLEAN(),
  61. nullable=False)
  62. batch_op.alter_column('post_count',
  63. existing_type=sa.INTEGER(),
  64. nullable=False)
  65. batch_op.alter_column('views',
  66. existing_type=sa.INTEGER(),
  67. nullable=False)
  68. with op.batch_alter_table('topicsread', schema=None) as batch_op:
  69. batch_op.alter_column('last_read',
  70. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  71. nullable=False)
  72. with op.batch_alter_table('users', schema=None) as batch_op:
  73. batch_op.alter_column('activated',
  74. existing_type=sa.BOOLEAN(),
  75. nullable=False)
  76. batch_op.alter_column('date_joined',
  77. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  78. nullable=False)
  79. batch_op.alter_column('login_attempts',
  80. existing_type=sa.INTEGER(),
  81. nullable=False)
  82. # ### end Alembic commands ###
  83. def downgrade():
  84. # ### commands auto generated by Alembic - please adjust! ###
  85. with op.batch_alter_table('users', schema=None) as batch_op:
  86. batch_op.alter_column('login_attempts',
  87. existing_type=sa.INTEGER(),
  88. nullable=True)
  89. batch_op.alter_column('date_joined',
  90. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  91. nullable=True)
  92. batch_op.alter_column('activated',
  93. existing_type=sa.BOOLEAN(),
  94. nullable=True)
  95. with op.batch_alter_table('topicsread', schema=None) as batch_op:
  96. batch_op.alter_column('last_read',
  97. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  98. nullable=True)
  99. with op.batch_alter_table('topics', schema=None) as batch_op:
  100. batch_op.alter_column('views',
  101. existing_type=sa.INTEGER(),
  102. nullable=True)
  103. batch_op.alter_column('post_count',
  104. existing_type=sa.INTEGER(),
  105. nullable=True)
  106. batch_op.alter_column('locked',
  107. existing_type=sa.BOOLEAN(),
  108. nullable=True)
  109. batch_op.alter_column('last_updated',
  110. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  111. nullable=True)
  112. batch_op.alter_column('important',
  113. existing_type=sa.BOOLEAN(),
  114. nullable=True)
  115. batch_op.alter_column('date_created',
  116. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  117. nullable=True)
  118. with op.batch_alter_table('reports', schema=None) as batch_op:
  119. batch_op.alter_column('reporter_id',
  120. existing_type=sa.INTEGER(),
  121. nullable=False)
  122. batch_op.alter_column('reported',
  123. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  124. nullable=True)
  125. batch_op.alter_column('post_id',
  126. existing_type=sa.INTEGER(),
  127. nullable=False)
  128. with op.batch_alter_table('posts', schema=None) as batch_op:
  129. batch_op.alter_column('date_created',
  130. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  131. nullable=True)
  132. with op.batch_alter_table('messages', schema=None) as batch_op:
  133. batch_op.alter_column('date_created',
  134. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  135. nullable=True)
  136. with op.batch_alter_table('groups_users', schema=None) as batch_op:
  137. batch_op.alter_column('user_id',
  138. existing_type=sa.INTEGER(),
  139. nullable=True)
  140. batch_op.alter_column('group_id',
  141. existing_type=sa.INTEGER(),
  142. nullable=True)
  143. with op.batch_alter_table('forumsread', schema=None) as batch_op:
  144. batch_op.alter_column('last_read',
  145. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  146. nullable=True)
  147. with op.batch_alter_table('conversations', schema=None) as batch_op:
  148. batch_op.alter_column('date_created',
  149. existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
  150. nullable=True)
  151. # ### end Alembic commands ###