1 """Use proper type and FK for booked_for_id
3 Revision ID: 3b997c7a4f0c
5 Create Date: 2015-05-06 14:04:14.590496
8 import sqlalchemy
as sa
12 # revision identifiers, used by Alembic.
13 revision
= '3b997c7a4f0c'
14 down_revision
= '2bb9dc6f5c28'
18 op
.execute('ALTER TABLE roombooking.reservations ALTER COLUMN booked_for_id TYPE int USING booked_for_id::int')
19 op
.create_foreign_key(None,
20 'reservations', 'users',
21 ['booked_for_id'], ['id'],
22 source_schema
='roombooking', referent_schema
='users')
23 op
.create_index(None, 'reservations', ['booked_for_id'], unique
=False, schema
='roombooking')
27 op
.drop_index(op
.f('ix_reservations_booked_for_id'), table_name
='reservations', schema
='roombooking')
28 op
.drop_constraint('fk_reservations_booked_for_id_users', 'reservations', schema
='roombooking')
29 op
.alter_column('reservations', 'booked_for_id', type_
=sa
.String
, schema
='roombooking')