Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ services:
- ../.env
environment:
- JWT_KEY_DIR=/data/keys
- MIGRATION_ARTIFACT_ROOT=/data/migration_artifacts
- SKIP_DDL_ON_STARTUP=true
- DEMO_SUPER_ADMIN_EMAIL=${DEMO_SUPER_ADMIN_EMAIL:-super@demo.example}
- DEMO_SUPER_ADMIN_PASSWORD=${DEMO_SUPER_ADMIN_PASSWORD:-super-changeme}
Expand Down Expand Up @@ -190,6 +191,10 @@ services:
]
env_file:
- ../.env
environment:
- MIGRATION_ARTIFACT_ROOT=/data/migration_artifacts
volumes:
- apidata:/data
depends_on:
observal-init:
condition: service_completed_successfully
Expand Down
72 changes: 72 additions & 0 deletions observal-server/alembic/versions/010_migration_jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# SPDX-FileCopyrightText: 2026 Hari Srinivasan <harisrini21@gmail.com>
# SPDX-License-Identifier: AGPL-3.0-only

"""Add migration_jobs table for data migration tracking.

Revision ID: 010_migration_jobs
Revises: 1a79544a6936
"""

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSON, UUID

from alembic import op

revision = "010_migration_jobs"
down_revision = "1a79544a6936"
branch_labels = None
depends_on = None


def upgrade() -> None:
# Create PG enum types
migration_operation = sa.Enum("export", "import", "validate", name="migration_operation")
migration_scope = sa.Enum("postgres", "clickhouse", "both", name="migration_scope")
migration_status = sa.Enum("queued", "running", "completed", "failed", name="migration_status")

migration_operation.create(op.get_bind(), checkfirst=True)
migration_scope.create(op.get_bind(), checkfirst=True)
migration_status.create(op.get_bind(), checkfirst=True)

op.create_table(
"migration_jobs",
sa.Column("id", UUID(as_uuid=True), primary_key=True),
sa.Column("operation_type", migration_operation, nullable=False),
sa.Column("data_scope", migration_scope, nullable=False),
sa.Column("status", migration_status, nullable=False, server_default="queued"),
sa.Column("progress_phase", sa.String(50), nullable=True, server_default="queued"),
sa.Column("progress_pct", sa.Integer(), nullable=False, server_default="0"),
sa.Column("progress_message", sa.Text(), nullable=True),
sa.Column("progress_updated_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("created_by", UUID(as_uuid=True), nullable=True),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
sa.Column("started_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("finished_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("error_message", sa.Text(), nullable=True),
sa.Column("result_json", JSON(), nullable=True),
sa.Column("artifacts_json", JSON(), nullable=True),
sa.Column("artifact_dir", sa.Text(), nullable=True),
sa.Column("schema_version", sa.String(64), nullable=True),
sa.Column("org_id", UUID(as_uuid=True), nullable=True),
)

op.create_foreign_key(
"fk_migration_jobs_created_by",
"migration_jobs",
"users",
["created_by"],
["id"],
ondelete="SET NULL",
)
op.create_index("ix_migration_jobs_status", "migration_jobs", ["status"])


def downgrade() -> None:
op.drop_index("ix_migration_jobs_status", table_name="migration_jobs")
op.drop_constraint("fk_migration_jobs_created_by", "migration_jobs", type_="foreignkey")
op.drop_table("migration_jobs")

# Drop enum types
sa.Enum(name="migration_status").drop(op.get_bind(), checkfirst=True)
sa.Enum(name="migration_scope").drop(op.get_bind(), checkfirst=True)
sa.Enum(name="migration_operation").drop(op.get_bind(), checkfirst=True)
2 changes: 1 addition & 1 deletion observal-server/api/routes/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"""Admin routes package. Sub-modules register routes on the shared router."""

# Import sub-modules so they register their routes on the shared router.
from . import enterprise_settings, insights_models, org, retention, users # noqa: F401
from . import enterprise_settings, insights_models, migrate, org, retention, users # noqa: F401
from ._router import router # noqa: F401
Loading
Loading