Skip to content

Add cascades to job_platforms table

Jeremiah Bonney requested to merge jbonney/job_platform_cascade_delete into master

Before raising this MR, consider whether the following are required, and complete if so:

  • Unit tests
  • Metrics
  • Documentation update(s)

If not required, please explain in brief why not.

Description

This PR updates the job_platform table to have job deletes/updates cascade to it. Without this change the job pruner logic isn't able to function, as deletes of jobs from the DB fail with the following error:

sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) update or delete on table "jobs" violates foreign key constraint "job_platforms_job_name_fkey" on table "job_platforms"

Since SQLite doesn't support ALTER TABLE, the alembic migration has slightly different logic for SQLite, which uses a Batch migration.

Validation

Start up BuildGrid without this change with very short pruner-job-max-age and pruner-period values, then execute an action with a platform property. The pruner will fail to clean up the finished job with the error above. With this change, the job is able to be deleted along with records from the job_platforms table.

Edited by Jeremiah Bonney

Merge request reports