text: """initial commit
  
  Revision ID: 0d88405b5538
  Revises:
  Create Date: 2021-02-26 16:40:26.166724
  
  """
  from alembic import op
  import sqlalchemy as sa
  from sqlalchemy.dialects import postgresql
  
  # revision identifiers, used by Alembic.
  revision = '0d88405b5538'
  down_revision = None
  branch_labels = None
  depends_on = None
  
  
  def upgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.create_table('appsettings',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('key', sa.Text(), nullable=False),
              sa.Column('int_value', sa.Integer(), nullable=True),
              sa.Column('str_value', sa.Text(), nullable=True),
              sa.Column('float_value', sa.Float(), nullable=True),
              sa.Column('date_value', sa.Date(), nullable=True),
              sa.Column('time_value', sa.Time(), nullable=True),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_appsettings')),
              sa.UniqueConstraint('key', name=op.f('uq_appsettings_key')),
              sa.UniqueConstraint('uuid', name=op.f('uq_appsettings_uuid'))
              )
      op.create_table('groups',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('site_id', sa.String(length=50), nullable=False),
              sa.Column('name', sa.Text(), nullable=False),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_groups')),
              sa.UniqueConstraint('uuid', name=op.f('uq_groups_uuid'))
              )
      op.create_index(op.f('ix_groups_site_id'), 'groups', ['site_id'], unique=True)
      op.create_table('metadata',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('name', sa.Text(), nullable=False),
              sa.Column('regexp', sa.Text(), nullable=True),
              sa.Column('lintmessage', sa.Text(), nullable=True),
              sa.Column('datetimefmt', sa.Text(), nullable=True),
              sa.Column('datetimemode', sa.Enum('DATE', 'DATETIME', 'TIME', name='datetimemode'), nullable=True),
              sa.Column('mandatory', sa.Boolean(create_constraint=False), nullable=False),
              sa.Column('order', sa.Integer(), nullable=False),
              sa.Column('isfile', sa.Boolean(create_constraint=False), nullable=False),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_metadata')),
              sa.UniqueConstraint('uuid', name=op.f('uq_metadata_uuid'))
              )
      op.create_table('submissions',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('site_id', sa.String(length=50), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('date', sa.DateTime(), nullable=True),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_submissions')),
              sa.UniqueConstraint('uuid', name=op.f('uq_submissions_uuid'))
              )
      op.create_index(op.f('ix_submissions_site_id'), 'submissions', ['site_id'], unique=True)
      op.create_table('regrequests',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('fullname', sa.Text(), nullable=False),
              sa.Column('email', sa.Text(), nullable=False),
              sa.Column('group_id', sa.Integer(), nullable=True),
              sa.Column('new_group_name', sa.Text(), nullable=True),
              sa.ForeignKeyConstraint(['group_id'], ['groups.id'], name=op.f('fk_regrequests_group_id_groups')),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_regrequests')),
              sa.UniqueConstraint('uuid', name=op.f('uq_regrequests_uuid'))
              )
      op.create_table('users',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('site_id', sa.String(length=50), nullable=False),
              sa.Column('email', sa.Text(), nullable=True),
              sa.Column('fullname', sa.Text(), nullable=True),
              sa.Column('pwhash', sa.String(length=60), nullable=True),
              sa.Column('group_id', sa.Integer(), nullable=False),
              sa.Column('enabled', sa.Boolean(create_constraint=False), nullable=False),
              sa.Column('site_admin', sa.Boolean(create_constraint=False), nullable=False),
              sa.Column('group_admin', sa.Boolean(create_constraint=False), nullable=False),
              sa.ForeignKeyConstraint(['group_id'], ['groups.id'], name=op.f('fk_users_group_id_groups')),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_users')),
              sa.UniqueConstraint('email', name=op.f('uq_users_email')),
              sa.UniqueConstraint('uuid', name=op.f('uq_users_uuid'))
              )
      op.create_index(op.f('ix_users_site_id'), 'users', ['site_id'], unique=True)
      op.create_table('apikeys',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('user_id', sa.Integer(), nullable=False),
              sa.Column('value', sa.String(length=64), nullable=False),
              sa.Column('label', sa.String(length=200), nullable=True),
              sa.Column('expires', sa.DateTime(), nullable=True),
              sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_apikeys_user_id_users')),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_apikeys')),
              sa.UniqueConstraint('uuid', name=op.f('uq_apikeys_uuid'))
              )
      op.create_table('files',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('site_id', sa.String(length=50), nullable=False),
              sa.Column('name', sa.Text(), nullable=False),
              sa.Column('name_storage', sa.Text(), nullable=True),
              sa.Column('checksum', sa.Text(), nullable=False),
              sa.Column('filesize', sa.Integer(), nullable=False),
              sa.Column('checksum_crypt', sa.Text(), nullable=True),
              sa.Column('filesize_crypt', sa.Text(), nullable=True),
              sa.Column('user_id', sa.Integer(), nullable=False),
              sa.Column('group_id', sa.Integer(), nullable=False),
              sa.ForeignKeyConstraint(['group_id'], ['groups.id'], name=op.f('fk_files_group_id_groups')),
              sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_files_user_id_users')),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_files')),
              sa.UniqueConstraint('uuid', name=op.f('uq_files_uuid'))
              )
      op.create_index(op.f('ix_files_site_id'), 'files', ['site_id'], unique=True)
      op.create_table('metadatasets',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('site_id', sa.String(length=50), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('user_id', sa.Integer(), nullable=False),
              sa.Column('group_id', sa.Integer(), nullable=False),
              sa.Column('submission_id', sa.Integer(), nullable=True),
              sa.ForeignKeyConstraint(['group_id'], ['groups.id'], name=op.f('fk_metadatasets_group_id_groups')),
              sa.ForeignKeyConstraint(['submission_id'], ['submissions.id'], name=op.f('fk_metadatasets_submission_id_submissions')),
              sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_metadatasets_user_id_users')),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_metadatasets')),
              sa.UniqueConstraint('uuid', name=op.f('uq_metadatasets_uuid'))
              )
      op.create_index(op.f('ix_metadatasets_site_id'), 'metadatasets', ['site_id'], unique=True)
      op.create_table('passwordtokens',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('user_id', sa.Integer(), nullable=False),
              sa.Column('value', sa.Text(), nullable=False),
              sa.Column('expires', sa.DateTime(), nullable=False),
              sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_passwordtokens_user_id_users')),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_passwordtokens')),
              sa.UniqueConstraint('uuid', name=op.f('uq_passwordtokens_uuid')),
              sa.UniqueConstraint('value', name=op.f('uq_passwordtokens_value'))
              )
      op.create_table('metadatumrecords',
              sa.Column('id', sa.Integer(), nullable=False),
              sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
              sa.Column('metadatum_id', sa.Integer(), nullable=False),
              sa.Column('metadataset_id', sa.Integer(), nullable=False),
              sa.Column('file_id', sa.Integer(), nullable=True),
              sa.Column('value', sa.Text(), nullable=True),
              sa.ForeignKeyConstraint(['file_id'], ['files.id'], name=op.f('fk_metadatumrecords_file_id_files')),
              sa.ForeignKeyConstraint(['metadataset_id'], ['metadatasets.id'], name=op.f('fk_metadatumrecords_metadataset_id_metadatasets')),
              sa.ForeignKeyConstraint(['metadatum_id'], ['metadata.id'], name=op.f('fk_metadatumrecords_metadatum_id_metadata')),
              sa.PrimaryKeyConstraint('id', name=op.f('pk_metadatumrecords')),
              sa.UniqueConstraint('uuid', name=op.f('uq_metadatumrecords_uuid'))
              )
      # ### end Alembic commands ###
  
  
  def downgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.drop_table('metadatumrecords')
      op.drop_table('passwordtokens')
      op.drop_index(op.f('ix_metadatasets_site_id'), table_name='metadatasets')
      op.drop_table('metadatasets')
      op.drop_index(op.f('ix_files_site_id'), table_name='files')
      op.drop_table('files')
      op.drop_table('apikeys')
      op.drop_index(op.f('ix_users_site_id'), table_name='users')
      op.drop_table('users')
      op.drop_table('regrequests')
      op.drop_index(op.f('ix_submissions_site_id'), table_name='submissions')
      op.drop_table('submissions')
      op.drop_table('metadata')
      op.drop_index(op.f('ix_groups_site_id'), table_name='groups')
      op.drop_table('groups')
      op.drop_table('appsettings')
      # ### end Alembic commands ###
  