diff options
author | Clément Lassieur <clement@lassieur.org> | 2018-09-02 09:45:48 +0200 |
---|---|---|
committer | Clément Lassieur <clement@lassieur.org> | 2018-09-29 22:29:06 +0200 |
commit | 4e661552c3a0bebd9b584dcf72b9e949fb5582ef (patch) | |
tree | 83fa7b387ee0a5db7f902c6324c92d8dbc3287f2 /src/sql | |
parent | 8d40c49170971ad7bbf8b97336934dbb3d949fc1 (diff) | |
download | cuirass-4e661552c3a0bebd9b584dcf72b9e949fb5582ef.tar cuirass-4e661552c3a0bebd9b584dcf72b9e949fb5582ef.tar.gz |
database: Add builds only if one of their outputs is new.
* Makefile.am (dist_sql_DATA): Add 'src/sql/upgrade-4.sql'.
* src/cuirass/database.scm (db-add-output): New procedure.
(db-add-build): Call DB-ADD-OUTPUT, rollback the transaction and return #f if
DB-ADD-OUTPUT returned an empty list.
* src/schema.sql (Outputs): Set 'path' as primary key, instead of 'derivation,
name'.
* src/sql/upgrade-4.sql: New file with SQL queries to upgrade the database.
* tests/database.scm (make-dummy-build): Use the #:OUTPUTS key. Get default
OUTPUTS to depend on DRV.
("db-add-build-with-fixed-output"): New test.
Diffstat (limited to 'src/sql')
-rw-r--r-- | src/sql/upgrade-4.sql | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sql/upgrade-4.sql b/src/sql/upgrade-4.sql new file mode 100644 index 0000000..e567f03 --- /dev/null +++ b/src/sql/upgrade-4.sql @@ -0,0 +1,18 @@ +BEGIN TRANSACTION; + +ALTER TABLE Outputs RENAME TO tmp_Outputs; + +CREATE TABLE Outputs ( + derivation TEXT NOT NULL, + name TEXT NOT NULL, + path TEXT NOT NULL PRIMARY KEY, + FOREIGN KEY (derivation) REFERENCES Builds (derivation) +); + +INSERT OR IGNORE INTO Outputs (derivation, name, path) +SELECT derivation, name, path +FROM tmp_Outputs; + +DROP TABLE tmp_Outputs; + +COMMIT; |