diff --git a/alembic/versions/r8p6m2n4o5_add_device_id_to_oauth_grants.py b/alembic/versions/r8p6m2n4o5_add_device_id_to_oauth_grants.py new file mode 100644 index 0000000..6394f17 --- /dev/null +++ b/alembic/versions/r8p6m2n4o5_add_device_id_to_oauth_grants.py @@ -0,0 +1,29 @@ +"""Add device_id column to oauth_grants + +Revision ID: r8p6m2n4o5 +Revises: q7o5l1m3n4 +""" +from alembic import op +import sqlalchemy as sa + +revision = "r8p6m2n4o5" +down_revision = "q7o5l1m3n4" +branch_labels = None +depends_on = None + + +def upgrade(): + # device_id was added to the create_table migration after it had already + # run, so the column is missing from the live DB. Add it now. + op.add_column( + "oauth_grants", + sa.Column("device_id", sa.String(128), nullable=True), + ) + op.create_index( + "ix_oauth_grant_device", "oauth_grants", ["device_id", "client_id"] + ) + + +def downgrade(): + op.drop_index("ix_oauth_grant_device", table_name="oauth_grants") + op.drop_column("oauth_grants", "device_id")