eventcally/migrations/versions/021f602d9965_.py
Daniel Grams d63f340384 Internal/modules (#1)
* Restructured app
* Added Travis CI
* Added 'Deploy to heroku' button
2020-11-13 12:24:26 +01:00

80 lines
4.0 KiB
Python

"""empty message
Revision ID: 021f602d9965
Revises: 92f37474ad62
Create Date: 2020-10-22 17:59:27.823624
"""
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
from project import dbtypes
from project.models import EventRejectionReason, EventReviewStatus
# revision identifiers, used by Alembic.
revision = '021f602d9965'
down_revision = '92f37474ad62'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('eventsuggestion',
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=255), nullable=False),
sa.Column('start', sa.DateTime(timezone=True), nullable=False),
sa.Column('description', sa.UnicodeText(), nullable=True),
sa.Column('external_link', sa.String(length=255), nullable=True),
sa.Column('review_status', dbtypes.IntegerEnum(EventReviewStatus), nullable=True),
sa.Column('rejection_resaon', dbtypes.IntegerEnum(EventRejectionReason), nullable=True),
sa.Column('contact_name', sa.Unicode(length=255), nullable=False),
sa.Column('contact_email', sa.Unicode(length=255), nullable=True),
sa.Column('contact_phone', sa.Unicode(length=255), nullable=True),
sa.Column('admin_unit_id', sa.Integer(), nullable=False),
sa.Column('event_place_id', sa.Integer(), nullable=True),
sa.Column('event_place_text', sa.Unicode(length=255), nullable=True),
sa.Column('organizer_id', sa.Integer(), nullable=True),
sa.Column('organizer_text', sa.Unicode(length=255), nullable=True),
sa.Column('photo_id', sa.Integer(), nullable=True),
sa.Column('created_by_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['admin_unit_id'], ['adminunit.id'], ),
sa.ForeignKeyConstraint(['created_by_id'], ['user.id'], ),
sa.ForeignKeyConstraint(['event_place_id'], ['eventplace.id'], ),
sa.ForeignKeyConstraint(['organizer_id'], ['eventorganizer.id'], ),
sa.ForeignKeyConstraint(['photo_id'], ['image.id'], ),
sa.PrimaryKeyConstraint('id')
)
#op.drop_table('spatial_ref_sys')
op.drop_constraint('event_contact_id_fkey', 'event', type_='foreignkey')
op.drop_column('event', 'review_status')
op.drop_column('event', 'rejection_resaon')
op.drop_column('event', 'contact_id')
op.drop_column('eventcontact', 'email')
op.drop_column('eventcontact', 'name')
op.drop_column('eventcontact', 'phone')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('eventcontact', sa.Column('phone', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('eventcontact', sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False))
op.add_column('eventcontact', sa.Column('email', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('event', sa.Column('contact_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('event', sa.Column('rejection_resaon', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('event', sa.Column('review_status', sa.INTEGER(), autoincrement=False, nullable=True))
op.create_foreign_key('event_contact_id_fkey', 'event', 'eventcontact', ['contact_id'], ['id'])
op.create_table('spatial_ref_sys',
sa.Column('srid', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('auth_name', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
sa.Column('auth_srid', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('srtext', sa.VARCHAR(length=2048), autoincrement=False, nullable=True),
sa.Column('proj4text', sa.VARCHAR(length=2048), autoincrement=False, nullable=True),
sa.CheckConstraint('(srid > 0) AND (srid <= 998999)', name='spatial_ref_sys_srid_check'),
sa.PrimaryKeyConstraint('srid', name='spatial_ref_sys_pkey')
)
op.drop_table('eventsuggestion')
# ### end Alembic commands ###