ece44a2b50ef_.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. """empty message
  2. Revision ID: ece44a2b50ef
  3. Revises:
  4. Create Date: 2021-07-21 11:25:45.628242
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = 'ece44a2b50ef'
  10. down_revision = None
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. # ### commands auto generated by Alembic - please adjust! ###
  15. op.create_table('label_provider',
  16. sa.Column('id', sa.Integer(), nullable=False),
  17. sa.Column('name', sa.String(), nullable=False),
  18. sa.Column('description', sa.String(), nullable=True),
  19. sa.Column('root_folder', sa.String(), nullable=False),
  20. sa.PrimaryKeyConstraint('id'),
  21. sa.UniqueConstraint('root_folder')
  22. )
  23. op.create_table('model',
  24. sa.Column('id', sa.Integer(), nullable=False),
  25. sa.Column('name', sa.String(), nullable=False),
  26. sa.Column('description', sa.String(), nullable=True),
  27. sa.Column('root_folder', sa.String(), nullable=False),
  28. sa.Column('supports_encoded', sa.String(), nullable=False),
  29. sa.PrimaryKeyConstraint('id'),
  30. sa.UniqueConstraint('root_folder')
  31. )
  32. op.create_table('project',
  33. sa.Column('id', sa.Integer(), nullable=False),
  34. sa.Column('name', sa.String(), nullable=False),
  35. sa.Column('description', sa.String(), nullable=True),
  36. sa.Column('created', sa.DateTime(), nullable=False),
  37. sa.Column('model_id', sa.Integer(), nullable=True),
  38. sa.Column('label_provider_id', sa.Integer(), nullable=True),
  39. sa.Column('root_folder', sa.String(), nullable=False),
  40. sa.Column('external_data', sa.Boolean(), nullable=False),
  41. sa.Column('data_folder', sa.String(), nullable=False),
  42. sa.ForeignKeyConstraint(['label_provider_id'], ['label_provider.id'], ondelete='SET NULL'),
  43. sa.ForeignKeyConstraint(['model_id'], ['model.id'], ondelete='SET NULL'),
  44. sa.PrimaryKeyConstraint('id'),
  45. sa.UniqueConstraint('root_folder')
  46. )
  47. op.create_index(op.f('ix_project_created'), 'project', ['created'], unique=False)
  48. op.create_table('collection',
  49. sa.Column('id', sa.Integer(), nullable=False),
  50. sa.Column('name', sa.String(), nullable=False),
  51. sa.Column('project_id', sa.Integer(), nullable=False),
  52. sa.Column('reference', sa.String(), nullable=False),
  53. sa.Column('description', sa.String(), nullable=True),
  54. sa.Column('position', sa.Integer(), nullable=False),
  55. sa.Column('autoselect', sa.Boolean(), nullable=False),
  56. sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
  57. sa.PrimaryKeyConstraint('id'),
  58. sa.UniqueConstraint('project_id', 'reference')
  59. )
  60. op.create_table('label',
  61. sa.Column('id', sa.Integer(), nullable=False),
  62. sa.Column('name', sa.String(), nullable=False),
  63. sa.Column('project_id', sa.Integer(), nullable=False),
  64. sa.Column('parent_id', sa.Integer(), nullable=True),
  65. sa.Column('created', sa.DateTime(), nullable=False),
  66. sa.Column('reference', sa.String(), nullable=True),
  67. sa.ForeignKeyConstraint(['parent_id'], ['label.id'], ondelete='SET NULL'),
  68. sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
  69. sa.PrimaryKeyConstraint('id'),
  70. sa.UniqueConstraint('project_id', 'reference')
  71. )
  72. op.create_index(op.f('ix_label_created'), 'label', ['created'], unique=False)
  73. op.create_table('file',
  74. sa.Column('id', sa.Integer(), nullable=False),
  75. sa.Column('name', sa.String(), nullable=False),
  76. sa.Column('uuid', sa.String(), nullable=False),
  77. sa.Column('extension', sa.String(), nullable=False),
  78. sa.Column('type', sa.String(), nullable=False),
  79. sa.Column('size', sa.String(), nullable=False),
  80. sa.Column('created', sa.DateTime(), nullable=False),
  81. sa.Column('path', sa.String(), nullable=False),
  82. sa.Column('frames', sa.Integer(), nullable=True),
  83. sa.Column('fps', sa.Float(), nullable=True),
  84. sa.Column('project_id', sa.Integer(), nullable=False),
  85. sa.Column('collection_id', sa.Integer(), nullable=True),
  86. sa.ForeignKeyConstraint(['collection_id'], ['collection.id'], ondelete='SET NULL'),
  87. sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
  88. sa.PrimaryKeyConstraint('id'),
  89. sa.UniqueConstraint('project_id', 'path')
  90. )
  91. op.create_index(op.f('ix_file_created'), 'file', ['created'], unique=False)
  92. op.create_table('result',
  93. sa.Column('id', sa.Integer(), nullable=False),
  94. sa.Column('file_id', sa.Integer(), nullable=False),
  95. sa.Column('origin', sa.String(), nullable=False),
  96. sa.Column('type', sa.String(), nullable=False),
  97. sa.Column('label_id', sa.Integer(), nullable=True),
  98. sa.Column('data', sa.String(), nullable=True),
  99. sa.ForeignKeyConstraint(['file_id'], ['file.id'], ondelete='CASCADE'),
  100. sa.ForeignKeyConstraint(['label_id'], ['label.id'], ondelete='SET NULL'),
  101. sa.PrimaryKeyConstraint('id')
  102. )
  103. # ### end Alembic commands ###
  104. def downgrade():
  105. # ### commands auto generated by Alembic - please adjust! ###
  106. op.drop_table('result')
  107. op.drop_index(op.f('ix_file_created'), table_name='file')
  108. op.drop_table('file')
  109. op.drop_index(op.f('ix_label_created'), table_name='label')
  110. op.drop_table('label')
  111. op.drop_table('collection')
  112. op.drop_index(op.f('ix_project_created'), table_name='project')
  113. op.drop_table('project')
  114. op.drop_table('model')
  115. op.drop_table('label_provider')
  116. # ### end Alembic commands ###