feat: Add poblacion_apta service to docker-compose, enhance API gateway for new service integration, and update README with service details. Introduce new database tables for poblacion_apta_jobs and poblacion_apta_rows, and implement functionality for handling cop/mod calculations in the cleaning service.
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
"""Add poblacion_apta_jobs and poblacion_apta_rows tables.
|
||||
|
||||
Revision ID: 0006
|
||||
Revises: 0005
|
||||
Create Date: 2026-07-28
|
||||
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0006"
|
||||
down_revision: Union[str, None] = "0005"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
existing = set(inspector.get_table_names())
|
||||
|
||||
if "poblacion_apta_jobs" not in existing:
|
||||
op.create_table(
|
||||
"poblacion_apta_jobs",
|
||||
sa.Column("id", sa.String(36), primary_key=True),
|
||||
sa.Column("job_id", sa.String(36), sa.ForeignKey("jobs.id"), nullable=True),
|
||||
sa.Column("status", sa.String(32), nullable=False, server_default="pending"),
|
||||
sa.Column("request", sa.JSON, nullable=False, server_default="{}"),
|
||||
sa.Column("log", sa.JSON, nullable=False, server_default="[]"),
|
||||
sa.Column("summary", sa.JSON, nullable=False, server_default="{}"),
|
||||
sa.Column("error", sa.Text, nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
||||
)
|
||||
op.create_index("ix_poblacion_apta_jobs_job_id", "poblacion_apta_jobs", ["job_id"])
|
||||
op.create_index("ix_poblacion_apta_jobs_status", "poblacion_apta_jobs", ["status"])
|
||||
|
||||
if "poblacion_apta_rows" not in existing:
|
||||
op.create_table(
|
||||
"poblacion_apta_rows",
|
||||
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
|
||||
sa.Column(
|
||||
"poblacion_apta_job_id",
|
||||
sa.String(36),
|
||||
sa.ForeignKey("poblacion_apta_jobs.id"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("cleaning_job_id", sa.String(36), nullable=True),
|
||||
sa.Column("row_index", sa.Integer, nullable=False, server_default="0"),
|
||||
sa.Column("row_json", sa.JSON, nullable=False, server_default="{}"),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
)
|
||||
op.create_index(
|
||||
"ix_poblacion_apta_rows_poblacion_apta_job_id",
|
||||
"poblacion_apta_rows",
|
||||
["poblacion_apta_job_id"],
|
||||
)
|
||||
op.create_index(
|
||||
"ix_poblacion_apta_rows_cleaning_job_id",
|
||||
"poblacion_apta_rows",
|
||||
["cleaning_job_id"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
existing = set(inspector.get_table_names())
|
||||
if "poblacion_apta_rows" in existing:
|
||||
op.drop_index("ix_poblacion_apta_rows_cleaning_job_id", table_name="poblacion_apta_rows")
|
||||
op.drop_index(
|
||||
"ix_poblacion_apta_rows_poblacion_apta_job_id", table_name="poblacion_apta_rows"
|
||||
)
|
||||
op.drop_table("poblacion_apta_rows")
|
||||
if "poblacion_apta_jobs" in existing:
|
||||
op.drop_index("ix_poblacion_apta_jobs_status", table_name="poblacion_apta_jobs")
|
||||
op.drop_index("ix_poblacion_apta_jobs_job_id", table_name="poblacion_apta_jobs")
|
||||
op.drop_table("poblacion_apta_jobs")
|
||||
Reference in New Issue
Block a user