d4774c761a71_add_file.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """add_file
  2. Revision ID: d4774c761a71
  3. Revises: b87f52d28bb9
  4. Create Date: 2019-02-23 18:33:44.647531
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = 'd4774c761a71'
  10. down_revision = 'b87f52d28bb9'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.create_table('file',
  15. sa.Column('id', sa.Integer(), nullable=False),
  16. sa.Column('title', sa.String(), nullable=False),
  17. sa.Column('datetime', sa.DateTime(), nullable=True),
  18. sa.Column('path', sa.String(), nullable=False),
  19. sa.Column('identifier', sa.String(), nullable=True),
  20. sa.Column('user_id', sa.Integer(), nullable=True),
  21. sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
  22. sa.PrimaryKeyConstraint('id')
  23. )
  24. op.create_table('page_file',
  25. sa.Column('page_id', sa.Integer(), nullable=False),
  26. sa.Column('file_id', sa.Integer(), nullable=False),
  27. sa.ForeignKeyConstraint(['file_id'], ['file.id'], ),
  28. sa.ForeignKeyConstraint(['page_id'], ['page.id'], ),
  29. sa.PrimaryKeyConstraint('page_id', 'file_id')
  30. )
  31. def downgrade():
  32. op.drop_table('page_file')
  33. op.drop_table('file')