|
- <%
- '=======================================================================================================================
- ' MIGRATION: add_payload_to_jobs
- '=======================================================================================================================
- ' This migration was auto-generated. Add your migration logic below.
- '
- ' The migration object provides these helper methods:
- ' - migration.ExecuteSQL(sql) - Execute raw SQL
- ' - migration.CreateTable(name, columns) - Create a table
- ' - migration.DropTable(name) - Drop a table
- ' - migration.AddColumn(table, column, type) - Add a column
- ' - migration.DropColumn(table, column) - Drop a column
- ' - migration.CreateIndex(name, table, columns) - Create an index
- ' - migration.DropIndex(name, table) - Drop an index
- '
- ' For complex operations, use migration.DB to access the database directly:
- ' migration.DB.Execute "INSERT INTO users (name) VALUES (?)", Array("John")
- '
-
- '-----------------------------------------------------------------------------------------------------------------------
- ' UP - Apply the migration
- '-----------------------------------------------------------------------------------------------------------------------
- Sub Migration_Up(migration)
- ' Durable ingestion jobs (spec FR-016, NFR-002, AC-12): the normalized input is kept on the job until it succeeds,
- ' so an interrupted or failed job can be retried by the worker (core/lib.Jobs.asp).
- migration.AddColumn "jobs", "payload", "TEXT"
- migration.CreateIndex "idx_jobs_state", "jobs", "state, updated_at"
- ' Jobs left "running" by the old in-request code have no stored input and can never finish: close them.
- migration.ExecuteSQL "UPDATE jobs SET state = 'failed', error_code = 'interrupted', error_message = 'Interrupted before durable jobs existed; submit the document again.' WHERE state IN ('queued', 'running')"
- End Sub
-
- '-----------------------------------------------------------------------------------------------------------------------
- ' DOWN - Rollback the migration
- '-----------------------------------------------------------------------------------------------------------------------
- Sub Migration_Down(migration)
- ' Jobs closed by Up stay failed (their input never existed).
- migration.DropIndex "idx_jobs_state", "jobs"
- migration.DropColumn "jobs", "payload"
- End Sub
- %>
|