content: """add pipeline deployment [0d69e308846a].
  
  Revision ID: 0d69e308846a
  Revises: 8ad841ad9bfe
  Create Date: 2025-08-26 10:30:52.737833
  
  """
  
  import sqlalchemy as sa
  import sqlmodel
  from alembic import op
  from sqlalchemy.dialects import mysql
  
  # revision identifiers, used by Alembic.
  revision = "0d69e308846a"
  down_revision = "8ad841ad9bfe"
  branch_labels = None
  depends_on = None
  
  
  def upgrade() -> None:
      """Upgrade database schema and/or data, creating a new revision."""
      # ### commands auto generated by Alembic - please adjust! ###
      op.create_table(
          "deployment",
          sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
          sa.Column("created", sa.DateTime(), nullable=False),
          sa.Column("updated", sa.DateTime(), nullable=False),
          sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
          sa.Column("project_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
          sa.Column("user_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
          sa.Column(
              "status", sqlmodel.sql.sqltypes.AutoString(), nullable=False
          ),
          sa.Column("url", sa.TEXT(), nullable=True),
          sa.Column("auth_key", sa.TEXT(), nullable=True),
          sa.Column(
              "deployment_metadata",
              sa.String(length=16777215).with_variant(mysql.MEDIUMTEXT, "mysql"),
              nullable=False,
          ),
          sa.Column(
              "snapshot_id",
              sqlmodel.sql.sqltypes.GUID(),
              nullable=True,
          ),
          sa.Column("deployer_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
          sa.ForeignKeyConstraint(
              ["snapshot_id"],
              ["pipeline_snapshot.id"],
              name="fk_deployment_snapshot_id_pipeline_snapshot",
              ondelete="SET NULL",
          ),
          sa.ForeignKeyConstraint(
              ["deployer_id"],
              ["stack_component.id"],
              name="fk_deployment_deployer_id_stack_component",
              ondelete="SET NULL",
          ),
          sa.ForeignKeyConstraint(
              ["project_id"],
              ["project.id"],
              name="fk_deployment_project_id_project",
              ondelete="CASCADE",
          ),
          sa.ForeignKeyConstraint(
              ["user_id"],
              ["user.id"],
              name="fk_deployment_user_id_user",
              ondelete="SET NULL",
          ),
          sa.PrimaryKeyConstraint("id"),
          sa.UniqueConstraint(
              "name",
              "project_id",
              name="unique_deployment_name_in_project",
          ),
      )
      # ### end Alembic commands ###
  
  
  def downgrade() -> None:
      """Downgrade database schema and/or data back to the previous revision."""
      # ### commands auto generated by Alembic - please adjust! ###
      op.drop_table("deployment")
      # ### end Alembic commands ###
  