"""drop user_usage_tracking table

Revision ID: c4cc411768f2
Revises: e40df94401d2
Create Date: 2025-11-07 01:42:14.636928

"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "c4cc411768f2"
down_revision = "e40df94401d2"
branch_labels = None
depends_on = None


def upgrade() -> None:
  # ### commands auto generated by Alembic - please adjust! ###
  op.drop_index(op.f("idx_usage_type_time"), table_name="user_usage_tracking")
  op.drop_index(op.f("idx_user_usage_type_time"), table_name="user_usage_tracking")
  op.drop_index(
    op.f("ix_user_usage_tracking_occurred_at"), table_name="user_usage_tracking"
  )
  op.drop_index(
    op.f("ix_user_usage_tracking_usage_type"), table_name="user_usage_tracking"
  )
  op.drop_index(
    op.f("ix_user_usage_tracking_user_id"), table_name="user_usage_tracking"
  )
  op.drop_table("user_usage_tracking")
  # ### end Alembic commands ###


def downgrade() -> None:
  # ### commands auto generated by Alembic - please adjust! ###
  op.create_table(
    "user_usage_tracking",
    sa.Column("id", sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column("user_id", sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column("usage_type", sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column(
      "occurred_at", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
    ),
    sa.Column("endpoint", sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column("graph_id", sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column("resource_count", sa.INTEGER(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(
      ["user_id"], ["users.id"], name=op.f("user_usage_tracking_user_id_fkey")
    ),
    sa.PrimaryKeyConstraint("id", name=op.f("user_usage_tracking_pkey")),
  )
  op.create_index(
    op.f("ix_user_usage_tracking_user_id"),
    "user_usage_tracking",
    ["user_id"],
    unique=False,
  )
  op.create_index(
    op.f("ix_user_usage_tracking_usage_type"),
    "user_usage_tracking",
    ["usage_type"],
    unique=False,
  )
  op.create_index(
    op.f("ix_user_usage_tracking_occurred_at"),
    "user_usage_tracking",
    ["occurred_at"],
    unique=False,
  )
  op.create_index(
    op.f("idx_user_usage_type_time"),
    "user_usage_tracking",
    ["user_id", "usage_type", "occurred_at"],
    unique=False,
  )
  op.create_index(
    op.f("idx_usage_type_time"),
    "user_usage_tracking",
    ["usage_type", "occurred_at"],
    unique=False,
  )
  # ### end Alembic commands ###
