"""gps devicetoken on cascade

Peek Plugin Database Migration Script

Revision ID: 2561b7732a6c
Revises: 7f628c121c4c
Create Date: 2021-06-21 12:35:40.919747

"""

# revision identifiers, used by Alembic.
revision = "2561b7732a6c"
down_revision = "7f628c121c4c"
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("GpsLocation_deviceToken_fkey", "GpsLocation")
    op.drop_constraint(
        "GpsLocationHistory_deviceToken_fkey", "GpsLocationHistory"
    )

    op.create_foreign_key(
        "GpsLocation_deviceToken_fkey",
        "GpsLocation",
        "DeviceInfo",
        ["deviceToken"],
        ["deviceToken"],
        ondelete="CASCADE",
    )
    op.create_foreign_key(
        "GpsLocationHistory_deviceToken_fkey",
        "GpsLocationHistory",
        "DeviceInfo",
        ["deviceToken"],
        ["deviceToken"],
        ondelete="CASCADE",
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("GpsLocation_deviceToken_fkey", "GpsLocation")
    op.drop_constraint(
        "GpsLocationHistory_deviceToken_fkey", "GpsLocationHistory"
    )

    op.create_foreign_key(
        "GpsLocation_deviceToken_fkey",
        "GpsLocation",
        "DeviceInfo",
        ["deviceToken"],
        ["deviceToken"],
    )
    op.create_foreign_key(
        "GpsLocationHistory_deviceToken_fkey",
        "GpsLocationHistory",
        "DeviceInfo",
        ["deviceToken"],
        ["deviceToken"],
    )
    # ### end Alembic commands ###
