|
|
|
"""Added tables for Solar data and authentication.
|
|
|
|
|
|
|
|
Revision ID: c6edf87b8bff
|
|
|
|
Revises: a846faa2b908
|
|
|
|
Create Date: 2021-05-03 10:12:50.632988
|
|
|
|
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
|
|
revision = 'c6edf87b8bff'
|
|
|
|
down_revision = 'a846faa2b908'
|
|
|
|
branch_labels = None
|
|
|
|
depends_on = None
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade():
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
|
|
op.drop_table('upload_solar')
|
|
|
|
op.drop_table('institution')
|
|
|
|
op.drop_table('stamps')
|
|
|
|
op.drop_table('registered_user')
|
|
|
|
op.drop_column('upload_regular', 'corpus_name')
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade():
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
|
|
op.add_column('upload_regular', sa.Column('corpus_name', sa.TEXT(), autoincrement=False, nullable=False))
|
|
|
|
op.create_table('institution',
|
|
|
|
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('institution_id_seq'::regclass)"), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('region', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('file_contract', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.PrimaryKeyConstraint('id', name='institution_pkey'),
|
|
|
|
postgresql_ignore_search_path=False
|
|
|
|
)
|
|
|
|
op.create_table('registered_user',
|
|
|
|
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('registered_user_id_seq'::regclass)"), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('email', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('role', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('pass_hash', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('active', sa.BOOLEAN(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('last_login', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('registered', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('institution', sa.INTEGER(), autoincrement=False, nullable=True),
|
|
|
|
sa.ForeignKeyConstraint(['institution'], ['institution.id'], name='registered_user_institution_fkey'),
|
|
|
|
sa.PrimaryKeyConstraint('id', name='registered_user_pkey'),
|
|
|
|
postgresql_ignore_search_path=False
|
|
|
|
)
|
|
|
|
op.create_table('stamps',
|
|
|
|
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('institution', sa.INTEGER(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('file_logo', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.ForeignKeyConstraint(['institution'], ['institution.id'], name='stamps_institution_fkey'),
|
|
|
|
sa.PrimaryKeyConstraint('id', name='stamps_pkey')
|
|
|
|
)
|
|
|
|
op.create_table('upload_solar',
|
|
|
|
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('upload_user', sa.INTEGER(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('institution', sa.INTEGER(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('upload_hash', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('corpus_name', sa.TEXT(), autoincrement=False, nullable=False),
|
|
|
|
sa.Column('program', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('subject', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('subject_custom', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('grade', sa.INTEGER(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('text_type', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('text_type_custom', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('school_year', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('grammar_corrections', sa.TEXT(), autoincrement=False, nullable=True),
|
|
|
|
sa.Column('upload_file_hashes', sa.ARRAY(sa.String()), nullable=True),
|
|
|
|
sa.ForeignKeyConstraint(['upload_user'], ['registered_user.id'], name='upload_upload_user_fkey'),
|
|
|
|
sa.ForeignKeyConstraint(['institution'], ['institution.id'], name='upload_institution_fkey'),
|
|
|
|
sa.PrimaryKeyConstraint('id', name='upload_pkey')
|
|
|
|
)
|
|
|
|
|
|
|
|
# Insert default admin user with username "admin" and pass "portal-admin".
|
|
|
|
op.execute('INSERT INTO registered_user(name, email, role, pass_hash, active) VALUES (\'admin\', \'admin@cjvt.si\', \'admin\', \'pbkdf2:sha256:150000$aPRDrEqF$f27256d6d57001770feb9e7012ea27252f4a3e5ea9989931368e466d798679ff\', TRUE);')
|
|
|
|
|
|
|
|
op.create_table('upload_predavanja',
|
|
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
|
|
sa.Column('upload_hash', sa.String(), nullable=False),
|
|
|
|
sa.Column('timestamp', sa.DateTime(), nullable=False),
|
|
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
|
|
sa.Column('address', sa.String(), nullable=False),
|
|
|
|
sa.Column('subject', sa.String(), nullable=False),
|
|
|
|
sa.Column('faculty', sa.String(), nullable=False),
|
|
|
|
sa.Column('email', sa.String(), nullable=False),
|
|
|
|
sa.Column('phone', sa.String(), nullable=True),
|
|
|
|
sa.Column('keywords', sa.String(), nullable=False),
|
|
|
|
sa.Column('agree_publish', sa.Boolean(), nullable=False),
|
|
|
|
sa.Column('file_contract', sa.String(), nullable=True),
|
|
|
|
sa.Column('upload_file_hashes', sa.ARRAY(sa.String()), nullable=True),
|
|
|
|
sa.PrimaryKeyConstraint('id')
|
|
|
|
)
|
|
|
|
|
|
|
|
# ### end Alembic commands ###
|