
# downgrade revision identifier, used by Alembic.
revision = '587c89cfa8ea'
down_revision = '2c0bfc379e01'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('files', sa.Column('weight', sa.Integer(),
                                     nullable=False, default=0))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('files', 'weight')
    ### end Alembic commands ###


# downgrade revision identifier, used by Alembic.
revision = '587c89cfa8ea'
down_revision = '2c0bfc379e01'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('files', sa.Column('weight',
                                     sa.Integer(),
                                     nullable=True,
                                     default=0))
    connection = op.get_bind()
    connection.execute('UPDATE files SET weight=0')
    op.alter_column('files',
                    'weight',
                    existing_type=sa.Integer,
                    nullable=False)


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('files', 'weight')
    ### end Alembic commands ###

Fix bug in migration script
Fix bug in migration script

  
  # downgrade revision identifier, used by Alembic.
  revision = '587c89cfa8ea'
  down_revision = '2c0bfc379e01'
  
  from alembic import op
  import sqlalchemy as sa
  
  
  def upgrade():
      ### commands auto generated by Alembic - please adjust! ###
-     op.add_column('files', sa.Column('weight', sa.Integer(),
+     op.add_column('files', sa.Column('weight',
+                                      sa.Integer(),
+                                      nullable=True,
-                                      nullable=False, default=0))
+                                      default=0))
-     ### end Alembic commands ###
+     connection = op.get_bind()
+     connection.execute('UPDATE files SET weight=0')
+     op.alter_column('files',
+                     'weight',
+                     existing_type=sa.Integer,
+                     nullable=False)
  
  
  def downgrade():
      ### commands auto generated by Alembic - please adjust! ###
      op.drop_column('files', 'weight')
      ### end Alembic commands ###
  
Fix bug in migration script
## Code Before:

# downgrade revision identifier, used by Alembic.
revision = '587c89cfa8ea'
down_revision = '2c0bfc379e01'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('files', sa.Column('weight', sa.Integer(),
                                     nullable=False, default=0))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('files', 'weight')
    ### end Alembic commands ###

## Instruction:
Fix bug in migration script
## Code After:

# downgrade revision identifier, used by Alembic.
revision = '587c89cfa8ea'
down_revision = '2c0bfc379e01'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('files', sa.Column('weight',
                                     sa.Integer(),
                                     nullable=True,
                                     default=0))
    connection = op.get_bind()
    connection.execute('UPDATE files SET weight=0')
    op.alter_column('files',
                    'weight',
                    existing_type=sa.Integer,
                    nullable=False)


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('files', 'weight')
    ### end Alembic commands ###
