Skip to content
Snippets Groups Projects
  • Mathieu Othacehe's avatar
    2c3440de
    Use the Build id as Jobs foreign key. · 2c3440de
    Mathieu Othacehe authored
    Join Build and Jobs tables using the build id instead of the build derivation
    to speed queries.
    
    * src/sql/upgrade-3.sql: New file.
    * Makefile.am (dist_sql_DATA): Add it.
    * src/schema.sql (Jobs)[derivation]: Replace it by ...
    [build]: this new column.
    * src/cuirass/database.scm (db-add-job, db-get-jobs): Adapt them.
    Use the Build id as Jobs foreign key.
    Mathieu Othacehe authored
    Join Build and Jobs tables using the build id instead of the build derivation
    to speed queries.
    
    * src/sql/upgrade-3.sql: New file.
    * Makefile.am (dist_sql_DATA): Add it.
    * src/schema.sql (Jobs)[derivation]: Replace it by ...
    [build]: this new column.
    * src/cuirass/database.scm (db-add-job, db-get-jobs): Adapt them.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
upgrade-3.sql 427 B
BEGIN TRANSACTION;

ALTER TABLE Jobs ADD COLUMN build INTEGER;
ALTER TABLE Jobs ADD CONSTRAINT fk_builds
   FOREIGN KEY (build)
   REFERENCES Builds(id);
UPDATE Jobs SET build = b.id FROM (SELECT Jobs.evaluation, Jobs.derivation, Builds.id FROM jobs JOIN Builds ON Jobs.derivation = Builds.derivation) b WHERE jobs.evaluation = b.evaluation and jobs.derivation = b.derivation;
ALTER TABLE Jobs DROP COLUMN derivation;

COMMIT;