poc: BigQuery - Add column updated_at to table execution_node#302
Draft
yuechao-qin wants to merge 1 commit into
Draft
poc: BigQuery - Add column updated_at to table execution_node#302yuechao-qin wants to merge 1 commit into
updated_at to table execution_node#302yuechao-qin wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds a self-maintaining
updated_atcolumn toexecution_node, needed as a change-tracking watermark for an upcoming BigQuery replication pipeline (hack-days prototype). The column stamps itself on insert and on every update via SQLAlchemy'sinsert_default/onupdate, so no application code needs to set it explicitly.Changes
backend_types_sql.py: Add_utcnow()helper and un-comment/replace theupdated_atcolumn onExecutionNodewith amapped_columnusinginsert_default=_utcnowandonupdate=_utcnow.onupdatefires on anyUPDATEto the row, not just specific field changes — this matters becausePipelineRunsApiService_Sql.terminate()only ever setsextra_data["desired_state"], nevercontainer_execution_statusdirectly.database_migrations.py:migrate_add_execution_node_updated_at_column: idempotentADD COLUMN, using Alembic'sbatch_alter_tableso the same code path covers SQLite/MySQL/PostgreSQL. ReturnsTrueonly when it actually adds the column (no logging on the no-op path, since this runs on every startup).backfill_execution_node_updated_at: idempotent bulkUPDATE ... WHERE updated_at IS NULL, stamping every pre-existing row with a single flat "now" timestamp.database_ops.py: Wires the migration intomigrate_db(), running the backfill only in the same startup that actually added the column (guarded by the migration function's return value).Tests:
test_database_migrations.py: coverage for the migration (adds when missing, no-ops silently on second call, column is queryable afterward) and the backfill (backfills nulls, leaves existing values untouched, idempotent on second call).test_sql_event_listeners.py: confirmsupdated_atis set on creation and bumped on both a status change and anextra_data-only change (no listener needed — plainonupdatecovers it).test_api_server_sql.py: regression test confirmingterminate()bumpsupdated_aton a running descendantExecutionNode, since it mutatesextra_datarather thancontainer_execution_status.Testing
Ran the full test suite locally — all passing (449 tests).
Notes
This is a hack-days prototype (
poc:prefix). The reverse migration (dropping the column) intentionally does not live in this repo — it's admin-only, testing/rollback tooling that lives entirely inoasis-backendsince that's the only place with real admin auth.