def upgrade(): op.create_table( 'art_show_application', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=True), sa.Column('artist_name', residue.CoerceUTF8(), nullable=False), sa.Column('panels', sa.Integer(), server_default='0', nullable=False), sa.Column('tables', sa.Integer(), server_default='0', nullable=False), sa.Column('description', residue.CoerceUTF8(), nullable=False), sa.Column('website', residue.CoerceUTF8(), nullable=False), sa.Column('special_needs', residue.CoerceUTF8(), nullable=False), sa.Column('status', sa.Integer(), server_default='172070601', nullable=False), sa.Column('admin_notes', residue.CoerceUTF8(), nullable=False), sa.Column('base_price', sa.Integer(), server_default='0', nullable=False), sa.Column('overridden_price', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['attendee_id'], ['attendee.id'], name=op.f('fk_art_show_application_attendee_id_attendee'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_art_show_application')))
def upgrade(): op.create_table( 'print_job', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=False), sa.Column('admin_id', residue.UUID(), nullable=False), sa.Column('admin_name', sa.Unicode(), server_default='', nullable=False), sa.Column('printer_id', sa.Unicode(), server_default='', nullable=False), sa.Column('reg_station', sa.Integer(), nullable=True), sa.Column('queued', residue.UTCDateTime(), nullable=True), sa.Column('printed', residue.UTCDateTime(), nullable=True), sa.Column('errors', sa.Unicode(), server_default='', nullable=False), sa.Column('is_minor', sa.Boolean(), nullable=False), sa.Column('json_data', postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.ForeignKeyConstraint( ['admin_id'], ['admin_account.id'], name=op.f('fk_print_queue_admin_id_admin_account')), sa.ForeignKeyConstraint( ['attendee_id'], ['attendee.id'], name=op.f('fk_print_queue_attendee_id_attendee')), sa.PrimaryKeyConstraint('id', name=op.f('pk_print_queue')))
def upgrade(): op.create_table('admin_access_group', sa.Column('admin_account_id', residue.UUID(), nullable=False), sa.Column('access_group_id', residue.UUID(), nullable=False), sa.ForeignKeyConstraint(['access_group_id'], ['access_group.id'], name=op.f('fk_admin_access_group_access_group_id_access_group')), sa.ForeignKeyConstraint(['admin_account_id'], ['admin_account.id'], name=op.f('fk_admin_access_group_admin_account_id_admin_account')), sa.UniqueConstraint('admin_account_id', 'access_group_id', name=op.f('uq_admin_access_group_admin_account_id')) ) op.create_index('ix_admin_access_group_access_group_id', 'admin_access_group', ['access_group_id'], unique=False) op.create_index('ix_admin_access_group_admin_account_id', 'admin_access_group', ['admin_account_id'], unique=False) connection = op.get_bind() admin_attendees = connection.execute(admin_account.select()) for attendee in admin_attendees: attendee_access_group = connection.execute( access_group.select().where(access_group.c.id == attendee.access_group_id) ).first() if attendee_access_group: connection.execute( admin_access_group.insert().values({ 'admin_account_id': attendee.id, 'access_group_id': attendee_access_group.id, }) ) op.drop_constraint('fk_admin_account_access_group_id_access_group', 'admin_account', type_='foreignkey') op.drop_column('admin_account', 'access_group_id')
def upgrade(): op.create_table( 'receipt_item', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=True), sa.Column('group_id', residue.UUID(), nullable=True), sa.Column('txn_id', residue.UUID(), nullable=True), sa.Column('fk_id', residue.UUID(), nullable=True), sa.Column('model', sa.Unicode(), server_default='', nullable=False), sa.Column('txn_type', sa.Integer(), server_default='186441959', nullable=False), sa.Column('item_type', sa.Integer(), server_default='224685583', nullable=False), sa.Column('amount', sa.Integer(), nullable=False), sa.Column('when', residue.UTCDateTime(), nullable=False), sa.Column('who', sa.Unicode(), server_default='', nullable=False), sa.Column('desc', sa.Unicode(), server_default='', nullable=False), sa.ForeignKeyConstraint( ['attendee_id'], ['attendee.id'], name=op.f('fk_receipt_item_attendee_id_attendee'), ondelete='SET NULL'), sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_receipt_item_group_id_group'), ondelete='SET NULL'), sa.ForeignKeyConstraint( ['txn_id'], ['stripe_transaction.id'], name=op.f('fk_receipt_item_txn_id_stripe_transaction'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_receipt_item')))
def upgrade(): op.create_table( 'mits_document', sa.Column('id', residue.UUID(), nullable=False), sa.Column('team_id', residue.UUID(), nullable=False), sa.Column('filename', sa.Unicode(), server_default='', nullable=False), sa.Column('description', sa.Unicode(), server_default='', nullable=False), sa.ForeignKeyConstraint( ['team_id'], ['mits_team.id'], name=op.f('fk_mits_document_team_id_mits_team')), sa.PrimaryKeyConstraint('id', name=op.f('pk_mits_document'))) if is_sqlite: with op.batch_alter_table( 'mits_team', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: batch_op.add_column( sa.Column('deleted', sa.Boolean(), server_default='False', nullable=False)) batch_op.add_column( sa.Column('duplicate_of', residue.UUID(), nullable=True)) else: op.add_column( 'mits_team', sa.Column('deleted', sa.Boolean(), server_default='False', nullable=False)) op.add_column('mits_team', sa.Column('duplicate_of', residue.UUID(), nullable=True))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'attendee_account', sa.Column('id', residue.UUID(), nullable=False), sa.Column('email', sa.Unicode(), server_default='', nullable=False), sa.Column('hashed', sa.Unicode(), server_default='', nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_attendee_account'))) op.create_table( 'attendee_attendee_account', sa.Column('attendee_id', residue.UUID(), nullable=False), sa.Column('attendee_account_id', residue.UUID(), nullable=False), sa.ForeignKeyConstraint( ['attendee_account_id'], ['attendee_account.id'], name=op. f('fk_attendee_attendee_account_attendee_account_id_attendee_account' )), sa.ForeignKeyConstraint( ['attendee_id'], ['attendee.id'], name=op.f('fk_attendee_attendee_account_attendee_id_attendee')), sa.UniqueConstraint( 'attendee_id', 'attendee_account_id', name=op.f('uq_attendee_attendee_account_attendee_id'))) op.create_index('ix_attendee_attendee_account_attendee_account_id', 'attendee_attendee_account', ['attendee_account_id'], unique=False) op.create_index('ix_attendee_attendee_account_attendee_id', 'attendee_attendee_account', ['attendee_id'], unique=False) op.alter_column('mits_team', 'concurrent_attendees', existing_type=sa.INTEGER(), nullable=False)
def upgrade(): op.create_table( 'mits_panel_application', sa.Column('id', residue.UUID(), nullable=False), sa.Column('team_id', residue.UUID(), nullable=False), sa.Column('name', sa.Unicode(), server_default='', nullable=False), sa.Column('description', sa.Unicode(), server_default='', nullable=False), sa.Column('length', sa.Integer(), server_default='212285177', nullable=False), sa.Column('participation_interest', sa.Boolean(), server_default='False', nullable=False), sa.ForeignKeyConstraint( ['team_id'], ['mits_team.id'], name=op.f('fk_mits_panel_application_team_id_mits_team')), sa.PrimaryKeyConstraint('id', name=op.f('pk_mits_panel_application'))) op.add_column('mits_team', sa.Column('showcase_interest', sa.Boolean(), nullable=True)) op.alter_column('mits_team', 'panel_interest', server_default=None, nullable=True)
def upgrade(): op.create_table('promo_code_group', sa.Column('id', residue.UUID(), nullable=False), sa.Column('name', sa.Unicode(), server_default='', nullable=False), sa.Column('code', sa.Unicode(), server_default='', nullable=False), sa.Column('buyer_id', residue.UUID(), nullable=True), sa.ForeignKeyConstraint(['buyer_id'], ['attendee.id'], name=op.f('fk_promo_code_group_buyer_id_attendee'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_promo_code_group')) ) op.add_column('promo_code', sa.Column('group_id', residue.UUID(), nullable=True)) op.create_foreign_key(op.f('fk_promo_code_group_id_promo_code_group'), 'promo_code', 'promo_code_group', ['group_id'], ['id'], ondelete='SET NULL')
def upgrade(): op.create_table('art_show_bidder', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=True), sa.Column('bidder_num', sa.Unicode(), server_default='', nullable=False), sa.Column('hotel_name', sa.Unicode(), server_default='', nullable=False), sa.Column('hotel_room_num', sa.Unicode(), server_default='', nullable=False), sa.Column('admin_notes', sa.Unicode(), server_default='', nullable=False), sa.Column('signed_up', residue.UTCDateTime(), nullable=True), sa.ForeignKeyConstraint(['attendee_id'], ['attendee.id'], name=op.f('fk_art_show_bidder_attendee_id_attendee'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_art_show_bidder')) )
def upgrade(): op.create_table('stripe_transaction', sa.Column('id', residue.UUID(), nullable=False), sa.Column('stripe_id', sa.Unicode(), server_default='', nullable=True), sa.Column('type', sa.Integer(), server_default='186441959', nullable=False), sa.Column('amount', sa.Integer(), nullable=False), sa.Column('when', residue.UTCDateTime(), nullable=False), sa.Column('who', sa.Unicode(), server_default='', nullable=False), sa.Column('desc', sa.Unicode(), server_default='', nullable=False), sa.Column('fk_id', residue.UUID(), nullable=False), sa.Column('fk_model', sa.Unicode(), server_default='', nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_stripe_transaction')) )
def upgrade(): op.create_table( 'attendee_tournament', sa.Column('id', residue.UUID(), nullable=False), sa.Column('first_name', sa.Unicode(), server_default='', nullable=False), sa.Column('last_name', sa.Unicode(), server_default='', nullable=False), sa.Column('email', sa.Unicode(), server_default='', nullable=False), sa.Column('cellphone', sa.Unicode(), server_default='', nullable=False), sa.Column('game', sa.Unicode(), server_default='', nullable=False), sa.Column('availability', sa.Unicode(), server_default='', nullable=False), sa.Column('format', sa.Unicode(), server_default='', nullable=False), sa.Column('experience', sa.Unicode(), server_default='', nullable=False), sa.Column('needs', sa.Unicode(), server_default='', nullable=False), sa.Column('why', sa.Unicode(), server_default='', nullable=False), sa.Column('volunteering', sa.Boolean(), server_default='False', nullable=False), sa.Column('status', sa.Integer(), server_default='239694250', nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_attendee_tournament')))
def upgrade(): op.create_table('promo_code', sa.Column('id', residue.UUID(), nullable=False), sa.Column('code', sa.Unicode(), server_default='', nullable=False), sa.Column('discount', sa.Integer(), nullable=True), sa.Column('discount_type', sa.Integer(), server_default='0', nullable=False), sa.Column('expiration_date', residue.UTCDateTime(), nullable=False), sa.Column('uses_allowed', sa.Integer(), nullable=True), sa.CheckConstraint("trim(code) != ''", name='ck_promo_code_non_empty_code'), sa.PrimaryKeyConstraint('id', name=op.f('pk_promo_code')) ) op.create_table('promo_code_word', sa.Column('id', residue.UUID(), nullable=False), sa.Column('word', sa.Unicode(), server_default='', nullable=False), sa.Column('part_of_speech', sa.Integer(), server_default='0', nullable=False), sa.CheckConstraint("trim(word) != ''", name='ck_promo_code_word_non_empty_word'), sa.PrimaryKeyConstraint('id', name=op.f('pk_promo_code_word')) ) if is_sqlite: def listen_for_reflect(inspector, table, column_info): """Adds parenthesis around SQLite datetime defaults for utcnow.""" if column_info['default'] == "datetime('now', 'utc')": column_info['default'] = utcnow_server_default with op.batch_alter_table( 'attendee', reflect_kwargs=dict(listeners=[('column_reflect', listen_for_reflect)])) as batch_op: batch_op.add_column(sa.Column('promo_code_id', residue.UUID(), nullable=True)) batch_op.create_foreign_key(op.f('fk_attendee_promo_code_id_promo_code'), 'promo_code', ['promo_code_id'], ['id']) else: op.add_column('attendee', sa.Column('promo_code_id', residue.UUID(), nullable=True)) op.create_foreign_key(op.f('fk_attendee_promo_code_id_promo_code'), 'attendee', 'promo_code', ['promo_code_id'], ['id']) op.create_index(op.f('ix_attendee_promo_code_id'), 'attendee', ['promo_code_id'], unique=False) op.create_index( op.f('uq_promo_code_normalized_code'), 'promo_code', [text("replace(replace(lower(code), '-', ''), ' ', '')")], unique=True) op.create_index( op.f('uq_promo_code_word_normalized_word_part_of_speech'), 'promo_code_word', [text('lower(trim(word))'), 'part_of_speech'], unique=True)
def upgrade(): op.create_table( 'api_token', sa.Column('id', residue.UUID(), nullable=False), sa.Column('admin_account_id', residue.UUID(), nullable=False), sa.Column('token', residue.UUID(), nullable=False), sa.Column('access', sa.Unicode(), server_default='', nullable=False), sa.Column('name', sa.Unicode(), server_default='', nullable=False), sa.Column('description', sa.Unicode(), server_default='', nullable=False), sa.Column('issued_time', residue.UTCDateTime(), nullable=False), sa.Column('revoked_time', residue.UTCDateTime(), nullable=True), sa.ForeignKeyConstraint( ['admin_account_id'], ['admin_account.id'], name=op.f('fk_api_token_admin_account_id_admin_account')), sa.PrimaryKeyConstraint('id', name=op.f('pk_api_token')))
def upgrade(): op.add_column('mits_document', sa.Column('game_id', residue.UUID(), nullable=False)) op.drop_constraint('fk_mits_document_team_id_mits_team', 'mits_document', type_='foreignkey') op.create_foreign_key(op.f('fk_mits_document_game_id_mits_game'), 'mits_document', 'mits_game', ['game_id'], ['id']) op.drop_column('mits_document', 'team_id') op.add_column('mits_picture', sa.Column('game_id', residue.UUID(), nullable=False)) op.drop_constraint('fk_mits_picture_team_id_mits_team', 'mits_picture', type_='foreignkey') op.create_foreign_key(op.f('fk_mits_picture_game_id_mits_game'), 'mits_picture', 'mits_game', ['game_id'], ['id']) op.drop_column('mits_picture', 'team_id')
def upgrade(): op.create_table('api_job', sa.Column('id', residue.UUID(), nullable=False), sa.Column('admin_id', residue.UUID(), nullable=False), sa.Column('admin_name', sa.Unicode(), server_default='', nullable=False), sa.Column('queued', residue.UTCDateTime(), nullable=True), sa.Column('completed', residue.UTCDateTime(), nullable=True), sa.Column('cancelled', residue.UTCDateTime(), nullable=True), sa.Column('job_name', sa.Unicode(), server_default='', nullable=False), sa.Column('target_server', sa.Unicode(), server_default='', nullable=False), sa.Column('query', sa.Unicode(), server_default='', nullable=False), sa.Column('api_token', sa.Unicode(), server_default='', nullable=False), sa.Column('errors', sa.Unicode(), server_default='', nullable=False), sa.Column('json_data', postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.ForeignKeyConstraint(['admin_id'], ['admin_account.id'], name=op.f('fk_api_job_admin_id_admin_account')), sa.PrimaryKeyConstraint('id', name=op.f('pk_api_job')) )
def downgrade(): if is_sqlite: with op.batch_alter_table( 'attendee', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: batch_op.add_column( sa.Column('requested_any_dept', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False)) else: op.add_column( 'attendee', sa.Column('requested_any_dept', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False)) connection = op.get_bind() requests_for_any = connection.execute( dept_membership_request_table.select().where( dept_membership_request_table.c.department_id == None)) for request in requests_for_any: connection.execute(attendee_table.update().where( attendee_table.c.id == request.attendee_id).values( {'requested_any_dept': True})) connection.execute(dept_membership_request_table.delete().where( dept_membership_request_table.c.department_id == None)) if is_sqlite: with op.batch_alter_table( 'dept_membership_request', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: batch_op.drop_column('id') batch_op.alter_column('department_id', existing_type=residue.UUID(), nullable=False) else: op.drop_column('dept_membership_request', 'id') op.alter_column('dept_membership_request', 'department_id', existing_type=residue.UUID(), nullable=False)
def upgrade(): op.create_table( 'access_group', sa.Column('id', residue.UUID(), nullable=False), sa.Column('name', sa.Unicode(), server_default='', nullable=False), sa.Column('access', postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.Column('read_only_access', postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_access_group'))) op.add_column('admin_account', sa.Column('access_group_id', residue.UUID(), nullable=True)) op.create_foreign_key( op.f('fk_admin_account_access_group_id_access_group'), 'admin_account', 'access_group', ['access_group_id'], ['id'], ondelete='SET NULL')
def upgrade(): op.create_table( 'prev_season_supporter', sa.Column('id', residue.UUID(), nullable=False), sa.Column('first_name', sa.Unicode(), server_default='', nullable=False), sa.Column('last_name', sa.Unicode(), server_default='', nullable=False), sa.Column('email', sa.Unicode(), server_default='', nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_prev_season_supporter'))) op.create_table( 'season_pass_ticket', sa.Column('id', residue.UUID(), nullable=False), sa.Column('fk_id', residue.UUID(), nullable=False), sa.Column('slug', sa.Unicode(), server_default='', nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_season_pass_ticket')))
def upgrade(): op.create_table('attraction', sa.Column('id', residue.UUID(), nullable=False), sa.Column('name', sa.Unicode(), server_default='', nullable=False, unique=True), sa.Column('description', sa.Unicode(), server_default='', nullable=False), sa.Column('notifications', residue.JSON(), server_default='[]', nullable=False), sa.Column('required_checkin', sa.Integer(), server_default='0', nullable=False), sa.Column('restriction', sa.Integer(), server_default='0', nullable=False), sa.Column('department_id', residue.UUID(), nullable=True), sa.Column('owner_id', residue.UUID(), nullable=False), sa.ForeignKeyConstraint(['department_id'], ['department.id'], name=op.f('fk_attraction_department_id_department')), sa.ForeignKeyConstraint(['owner_id'], ['admin_account.id'], name=op.f('fk_attraction_owner_id_admin_account')), sa.PrimaryKeyConstraint('id', name=op.f('pk_attraction')), ) op.create_table('attraction_feature', sa.Column('id', residue.UUID(), nullable=False), sa.Column('name', sa.Unicode(), server_default='', nullable=False), sa.Column('description', sa.Unicode(), server_default='', nullable=False), sa.Column('attraction_id', residue.UUID(), nullable=False), sa.ForeignKeyConstraint(['attraction_id'], ['attraction.id'], name=op.f('fk_attraction_feature_attraction_id_attraction')), sa.PrimaryKeyConstraint('id', name=op.f('pk_attraction_feature')), sa.UniqueConstraint('name', 'attraction_id'), ) op.create_table('attraction_event', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attraction_feature_id', residue.UUID(), nullable=False), sa.Column('location', sa.Integer(), nullable=False), sa.Column('start_time', residue.UTCDateTime(), nullable=False), sa.Column('duration', sa.Integer(), server_default='900', nullable=False), sa.Column('slots', sa.Integer(), server_default='1', nullable=False), sa.ForeignKeyConstraint(['attraction_feature_id'], ['attraction_feature.id'], name=op.f('fk_attraction_event_attraction_feature_id_attraction_feature')), sa.PrimaryKeyConstraint('id', name=op.f('pk_attraction_event')), ) op.create_table('attraction_signup', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attraction_event_id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=False), sa.Column('signup_time', residue.UTCDateTime(), server_default=sa.text(utcnow_server_default), nullable=False), sa.Column('checkin_time', residue.UTCDateTime(), nullable=True), sa.ForeignKeyConstraint(['attendee_id'], ['attendee.id'], name=op.f('fk_attraction_signup_attendee_id_attendee')), sa.ForeignKeyConstraint(['attraction_event_id'], ['attraction_event.id'], name=op.f('fk_attraction_signup_attraction_event_id_attraction_event')), sa.PrimaryKeyConstraint('id', name=op.f('pk_attraction_signup')), sa.UniqueConstraint('attraction_event_id', 'attendee_id', name=op.f('uq_attraction_signup_attraction_event_id')) )
def upgrade(): op.create_table('art_show_piece', sa.Column('id', residue.UUID(), nullable=False), sa.Column('app_id', residue.UUID(), nullable=True), sa.Column('piece_id', sa.Integer(), nullable=False), sa.Column('name', sa.Unicode(), server_default='', nullable=False), sa.Column('for_sale', sa.Boolean(), server_default='False', nullable=False), sa.Column('type', sa.Integer(), server_default='36230926', nullable=False), sa.Column('gallery', sa.Integer(), server_default='187837110', nullable=False), sa.Column('media', sa.Unicode(), server_default='', nullable=False), sa.Column('print_run_num', sa.Integer(), server_default='0', nullable=True), sa.Column('print_run_total', sa.Integer(), server_default='0', nullable=True), sa.Column('opening_bid', sa.Integer(), server_default='0', nullable=True), sa.Column('quick_sale_price', sa.Integer(), server_default='0', nullable=True), sa.Column('no_quick_sale', sa.Boolean(), server_default='False', nullable=False), sa.Column('status', sa.Integer(), server_default='34456864', nullable=False), sa.ForeignKeyConstraint(['app_id'], ['art_show_application.id'], name=op.f('fk_art_show_pieces_app_id_art_show_application'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_art_show_pieces')) )
def upgrade(): op.create_table('marketplace_application', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=True), sa.Column('business_name', sa.Unicode(), server_default='', nullable=False), sa.Column('status', sa.Integer(), server_default='172070601', nullable=False), sa.Column('registered', residue.UTCDateTime(), server_default=sa.text("timezone('utc', current_timestamp)"), nullable=False), sa.Column('approved', residue.UTCDateTime(), nullable=True), sa.Column('categories', sa.Unicode(), server_default='', nullable=False), sa.Column('categories_text', sa.Unicode(), server_default='', nullable=False), sa.Column('description', sa.Unicode(), server_default='', nullable=False), sa.Column('special_needs', sa.Unicode(), server_default='', nullable=False), sa.Column('admin_notes', sa.Unicode(), server_default='', nullable=False), sa.Column('base_price', sa.Integer(), server_default='0', nullable=False), sa.Column('overridden_price', sa.Integer(), nullable=True), sa.Column('amount_paid', sa.Integer(), server_default='0', nullable=False), sa.ForeignKeyConstraint(['attendee_id'], ['attendee.id'], name=op.f('fk_marketplace_application_attendee_id_attendee'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_marketplace_application')) ) op.create_index(op.f('ix_marketplace_application_amount_paid'), 'marketplace_application', ['amount_paid'], unique=False)
def upgrade(): op.create_table( 'art_show_receipt', sa.Column('id', residue.UUID(), nullable=False), sa.Column('invoice_num', sa.Integer(), server_default='0', nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=True), sa.Column('closed', residue.UTCDateTime(), nullable=True), sa.ForeignKeyConstraint( ['attendee_id'], ['attendee.id'], name=op.f('fk_art_show_receipt_attendee_id_attendee'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_art_show_receipt'))) op.create_table( 'art_show_payment', sa.Column('id', residue.UUID(), nullable=False), sa.Column('receipt_id', residue.UUID(), nullable=True), sa.Column('amount', sa.Integer(), server_default='0', nullable=False), sa.Column('type', sa.Integer(), server_default='180350097', nullable=False), sa.Column('when', residue.UTCDateTime(), nullable=False), sa.ForeignKeyConstraint( ['receipt_id'], ['art_show_receipt.id'], name=op.f('fk_art_show_payment_receipt_id_art_show_receipt'), ondelete='SET NULL'), sa.PrimaryKeyConstraint('id', name=op.f('pk_art_show_payment'))) op.add_column('art_show_piece', sa.Column('receipt_id', residue.UUID(), nullable=True)) op.add_column( 'art_show_piece', sa.Column('winning_bid', sa.Integer(), server_default='0', nullable=True)) op.create_foreign_key( op.f('fk_art_show_piece_receipt_id_art_show_receipt'), 'art_show_piece', 'art_show_receipt', ['receipt_id'], ['id'], ondelete='SET NULL')
def upgrade(): op.create_table('guest_autograph', sa.Column('id', residue.UUID(), nullable=False), sa.Column('guest_id', residue.UUID(), nullable=False), sa.Column('num', sa.Integer(), server_default='0', nullable=False), sa.Column('length', sa.Integer(), server_default='60', nullable=False), sa.ForeignKeyConstraint(['guest_id'], ['guest_group.id'], name=op.f('fk_guest_autograph_guest_id_guest_group')), sa.PrimaryKeyConstraint('id', name=op.f('pk_guest_autograph')), sa.UniqueConstraint('guest_id', name=op.f('uq_guest_autograph_guest_id')) ) op.create_table('guest_interview', sa.Column('id', residue.UUID(), nullable=False), sa.Column('guest_id', residue.UUID(), nullable=False), sa.Column('will_interview', sa.Boolean(), server_default='False', nullable=False), sa.Column('email', sa.Unicode(), server_default='', nullable=False), sa.Column('direct_contact', sa.Boolean(), server_default='False', nullable=False), sa.ForeignKeyConstraint(['guest_id'], ['guest_group.id'], name=op.f('fk_guest_interview_guest_id_guest_group')), sa.PrimaryKeyConstraint('id', name=op.f('pk_guest_interview')), sa.UniqueConstraint('guest_id', name=op.f('uq_guest_interview_guest_id')) ) op.create_table('guest_travel_plans', sa.Column('id', residue.UUID(), nullable=False), sa.Column('guest_id', residue.UUID(), nullable=False), sa.Column('modes', sa.Unicode(), server_default='', nullable=False), sa.Column('modes_text', sa.Unicode(), server_default='', nullable=False), sa.Column('details', sa.Unicode(), server_default='', nullable=False), sa.ForeignKeyConstraint(['guest_id'], ['guest_group.id'], name=op.f('fk_guest_travel_plans_guest_id_guest_group')), sa.PrimaryKeyConstraint('id', name=op.f('pk_guest_travel_plans')), sa.UniqueConstraint('guest_id', name=op.f('uq_guest_travel_plans_guest_id')) )
def upgrade(): op.add_column('password_reset', sa.Column('admin_id', residue.UUID(), nullable=True)) op.add_column('password_reset', sa.Column('attendee_id', residue.UUID(), nullable=True)) op.create_unique_constraint(op.f('uq_password_reset_admin_id'), 'password_reset', ['admin_id']) op.create_unique_constraint(op.f('uq_password_reset_attendee_id'), 'password_reset', ['attendee_id']) op.drop_constraint('uq_password_reset_account_id', 'password_reset', type_='unique') op.drop_constraint('fk_password_reset_account_id_admin_account', 'password_reset', type_='foreignkey') op.create_foreign_key(op.f('fk_password_reset_admin_id_admin_account'), 'password_reset', 'admin_account', ['admin_id'], ['id']) op.create_foreign_key( op.f('fk_password_reset_attendee_id_attendee_account'), 'password_reset', 'attendee_account', ['attendee_id'], ['id']) op.drop_column('password_reset', 'account_id')
def upgrade(): op.add_column( 'art_show_application', sa.Column('agent_code', sa.Unicode(), server_default='', nullable=False)) op.add_column('art_show_application', sa.Column('agent_id', residue.UUID(), nullable=True)) op.create_foreign_key(op.f('fk_art_show_application_agent_id_attendee'), 'art_show_application', 'attendee', ['agent_id'], ['id'], ondelete='SET NULL') op.drop_column('art_show_application', 'agent_name')
def upgrade(): op.create_table('room', sa.Column('id', residue.UUID(), nullable=False), sa.Column('notes', sa.Unicode(), server_default='', nullable=False), sa.Column('message', sa.Unicode(), server_default='', nullable=False), sa.Column('locked_in', sa.Boolean(), server_default='False', nullable=False), sa.Column('nights', sa.Unicode(), server_default='', nullable=False), sa.Column('created', residue.UTCDateTime(), server_default=sa.text(utcnow_server_default), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_room')) ) op.create_table('hotel_requests', sa.Column('id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=False), sa.Column('nights', sa.Unicode(), server_default='', nullable=False), sa.Column('wanted_roommates', sa.Unicode(), server_default='', nullable=False), sa.Column('unwanted_roommates', sa.Unicode(), server_default='', nullable=False), sa.Column('special_needs', sa.Unicode(), server_default='', nullable=False), sa.Column('approved', sa.Boolean(), server_default='False', nullable=False), sa.ForeignKeyConstraint(['attendee_id'], ['attendee.id'], name=op.f('fk_hotel_requests_attendee_id_attendee')), sa.PrimaryKeyConstraint('id', name=op.f('pk_hotel_requests')), sa.UniqueConstraint('attendee_id', name=op.f('uq_hotel_requests_attendee_id')) ) op.create_table('room_assignment', sa.Column('id', residue.UUID(), nullable=False), sa.Column('room_id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=False), sa.ForeignKeyConstraint(['attendee_id'], ['attendee.id'], name=op.f('fk_room_assignment_attendee_id_attendee')), sa.ForeignKeyConstraint(['room_id'], ['room.id'], name=op.f('fk_room_assignment_room_id_room')), sa.PrimaryKeyConstraint('id', name=op.f('pk_room_assignment')) ) if is_sqlite: with op.batch_alter_table('attendee', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: batch_op.add_column(sa.Column('hotel_eligible', sa.Boolean(), server_default='False', nullable=False)) else: op.add_column('attendee', sa.Column('hotel_eligible', sa.Boolean(), server_default='False', nullable=False))
# =========================================================================== # HOWTO: Handle alter statements in SQLite # # def upgrade(): # if is_sqlite: # with op.batch_alter_table('table_name', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: # batch_op.alter_column('column_name', type_=sa.Unicode(), server_default='', nullable=False) # else: # op.alter_column('table_name', 'column_name', type_=sa.Unicode(), server_default='', nullable=False) # # =========================================================================== attraction_table = table( 'attraction', sa.Column('id', residue.UUID()), sa.Column('name', sa.Unicode()), sa.Column('slug', sa.Boolean()), ) attraction_feature_table = table( 'attraction_feature', sa.Column('id', residue.UUID()), sa.Column('name', sa.Unicode()), sa.Column('slug', sa.Boolean()), ) def upgrade(): if is_sqlite:
def upgrade(): op.create_table( 'stripe_transaction_group', sa.Column('id', residue.UUID(), nullable=False), sa.Column('txn_id', residue.UUID(), nullable=False), sa.Column('group_id', residue.UUID(), nullable=False), sa.Column('share', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['group_id'], ['group.id'], name=op.f('fk_stripe_transaction_group_group_id_group')), sa.ForeignKeyConstraint( ['txn_id'], ['stripe_transaction.id'], name=op.f( 'fk_stripe_transaction_group_txn_id_stripe_transaction')), sa.PrimaryKeyConstraint('id', name=op.f('pk_stripe_transaction_group'))) op.create_table( 'stripe_transaction_attendee', sa.Column('id', residue.UUID(), nullable=False), sa.Column('txn_id', residue.UUID(), nullable=False), sa.Column('attendee_id', residue.UUID(), nullable=False), sa.Column('share', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['attendee_id'], ['attendee.id'], name=op.f('fk_stripe_transaction_attendee_attendee_id_attendee')), sa.ForeignKeyConstraint( ['txn_id'], ['stripe_transaction.id'], name=op.f( 'fk_stripe_transaction_attendee_txn_id_stripe_transaction')), sa.PrimaryKeyConstraint('id', name=op.f('pk_stripe_transaction_attendee'))) connection = op.get_bind() txns = connection.execute(stripe_txn_table.select()) errors = [] group_names = [ group.name for group in connection.execute(group_table.select()) ] comma_attendees = [ a.first_name + " " + a.last_name for a in connection.execute(attendee_table.select()) if ',' in a.first_name or ',' in a.last_name ] comma_groups = [ g.name for g in connection.execute(group_table.select()) if ',' in g.name ] for txn in txns: if ', ' in txn.desc: desc = txn.desc comma_names = [] for name in (comma_attendees + comma_groups): if name in desc: desc = desc.replace(name, '', 1) comma_names.append(name) name_list = desc.split( ', ') + comma_names if comma_names else desc.split(', ') first_name, last_name, error = add_model_by_txn(txn, True) saved_name = first_name + " " + last_name if txn.fk_model == "Attendee" else first_name if error: errors.append(error) else: if txn.fk_model == "Attendee": # We change attendees' name case in the DB, but not groups' # We want to remove names without title casing first # but only if there's no groups with that name for name in name_list: if first_name.upper() in name: remove_name = first_name.upper() elif first_name.lower() in name: remove_name = first_name.lower() else: remove_name = first_name if last_name.upper() in name: remove_name = remove_name + " " + last_name.upper() elif last_name.lower() in name: remove_name = remove_name + " " + last_name.lower() else: remove_name = remove_name + " " + last_name if remove_name not in group_names and remove_name in name_list: name_list.remove(remove_name) break else: name_list.remove(saved_name) for name in name_list: if not name: # This happens for single attendee transactions # where the attendee used a ', ' in their name continue matching_groups = [ txn for txn in connection.execute(group_table.select().where( and_(group_table.c.id != txn.fk_id, group_table.c.name == name))) ] # This only exists for one loop if we set it outside the loop attendees = connection.execute(attendee_table.select()) # This is a presave adjustment we make after the charge, but before saving an attendee if name.isupper() or name.islower(): name = name.title() matching_attendees = [ a for a in attendees if a.first_name + " " + a.last_name == name and a.id != txn.fk_id ] if not matching_attendees and not matching_groups: errors.append( 'Error: name not found for "{}"'.format(name)) continue if len(matching_attendees + matching_groups) != name_list.count(name): if "kicking in" in txn.desc: kickin_attendees = [ a for a in matching_attendees if a.amount_extra > 0 ] if len(kickin_attendees == 1): [attendee] = kickin_attendees add_attendee_txn(txn, attendee, txn.amount) continue if len(matching_groups ) == 1 and "extra badges" in txn.desc: [group] = matching_groups add_group_txn(txn, group, txn.amount) continue non_group_attendees = [ a for a in matching_attendees if a.paid != c.PAID_BY_GROUP ] if len(non_group_attendees) == 1: [attendee] = non_group_attendees add_attendee_txn(txn, attendee) continue errors.append( 'Error: there are {} attendees/groups named "{}" in the DB, but {} in the transaction' .format(len(matching_attendees + matching_groups), name, name_list.count(name))) name_list = [n for n in name_list if n != name] continue for attendee in matching_attendees: add_attendee_txn(txn, attendee) for group in matching_groups: add_group_txn(txn, group) else: first_name, last_name, error = add_model_by_txn(txn) if error: errors.append(error) for error in errors: print(error) op.drop_column('stripe_transaction', 'fk_id') op.drop_column('stripe_transaction', 'fk_model')
'listeners': [('column_reflect', sqlite_column_reflect_listener)] } # =========================================================================== # HOWTO: Handle alter statements in SQLite # # def upgrade(): # if is_sqlite: # with op.batch_alter_table('table_name', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: # batch_op.alter_column('column_name', type_=sa.Unicode(), server_default='', nullable=False) # else: # op.alter_column('table_name', 'column_name', type_=sa.Unicode(), server_default='', nullable=False) # # =========================================================================== stripe_txn_table = table('stripe_transaction', sa.Column('id', residue.UUID()), sa.Column('amount', sa.Integer()), sa.Column('desc', sa.Unicode()), sa.Column('fk_id', residue.UUID()), sa.Column('fk_model', sa.Unicode())) attendee_table = table('attendee', sa.Column('id', residue.UUID()), sa.Column('first_name', sa.Unicode()), sa.Column('last_name', sa.Unicode()), sa.Column('paid', sa.Integer()), sa.Column('amount_paid', sa.Integer()), sa.Column('amount_extra', sa.Integer())) group_table = table('group', sa.Column('id', residue.UUID()), sa.Column('leader_id', residue.UUID()), sa.Column('name', sa.Unicode()),
# =========================================================================== # HOWTO: Handle alter statements in SQLite # # def upgrade(): # if is_sqlite: # with op.batch_alter_table('table_name', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: # batch_op.alter_column('column_name', type_=sa.Unicode(), server_default='', nullable=False) # else: # op.alter_column('table_name', 'column_name', type_=sa.Unicode(), server_default='', nullable=False) # # =========================================================================== admin_account = table( 'admin_account', sa.Column('id', residue.UUID()), sa.Column('access_group_id', residue.UUID()), ) access_group = table( 'access_group', sa.Column('id', residue.UUID()), sa.Column('name', sa.Unicode()), sa.Column('access', sa.dialects.postgresql.json.JSONB()), sa.Column('read_only_access', sa.dialects.postgresql.json.JSONB()), ) admin_access_group = table( 'admin_access_group', sa.Column('admin_account_id', residue.UUID()), sa.Column('access_group_id', residue.UUID()),