diff options
author | Christopher Baines <mail@cbaines.net> | 2020-01-24 19:47:43 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-01-25 22:22:39 +0000 |
commit | fa412cdb5985ec4199f89510d8d8cde9b7664e2d (patch) | |
tree | d4650e78333873df4837840a11560e60ab83928c /src/sql | |
parent | 9eb96d1b197d674d34daf4de8c75fa9ee337f583 (diff) | |
download | cuirass-fa412cdb5985ec4199f89510d8d8cde9b7664e2d.tar cuirass-fa412cdb5985ec4199f89510d8d8cde9b7664e2d.tar.gz |
Alter the Builds table to have an id fieldimprove-handling-of-rowids
The internal rowid's are used for builds as you can request builds by using
the rowid in the URL.
The motivation here is to enable running VACUUM operations in SQLite, without
risking the rowid's for Builds changing. It would be bad if they change, as
they're used in the URL's for builds.
* src/schema.sql (Builds): Add id column.
* src/curiass/dataabse.scm (db-add-build): Change PRIMARYKEY constraint to
UNIQUE constraint.
* src/sql/upgrade-6.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
Diffstat (limited to 'src/sql')
-rw-r--r-- | src/sql/upgrade-6.sql | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/sql/upgrade-6.sql b/src/sql/upgrade-6.sql new file mode 100644 index 0000000..0b25aa5 --- /dev/null +++ b/src/sql/upgrade-6.sql @@ -0,0 +1,47 @@ +BEGIN TRANSACTION; + +ALTER TABLE Builds RENAME TO OldBuilds; + +CREATE TABLE Builds ( + id INTEGER NOT NULL PRIMARY KEY, + derivation TEXT NOT NULL UNIQUE, + evaluation INTEGER NOT NULL, + job_name TEXT NOT NULL, + system TEXT NOT NULL, + nix_name TEXT NOT NULL, + log TEXT NOT NULL, + status INTEGER NOT NULL, + timestamp INTEGER NOT NULL, + starttime INTEGER NOT NULL, + stoptime INTEGER NOT NULL, + FOREIGN KEY (evaluation) REFERENCES Evaluations (id) +); + +INSERT INTO Builds( + id, + derivation, + evaluation, + job_name, + system, + nix_name, + log, + status, + timestamp, + starttime, + stoptime +) SELECT rowid, + derivation, + evaluation, + job_name, + system, + nix_name, + log, + status, + timestamp, + starttime, + stoptime + FROM OldBuilds; + +DROP TABLE OldBuilds; + +COMMIT; |