Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Store target's custom meta data when installing #1370

Merged
merged 2 commits into from
Sep 23, 2019

Conversation

doanac
Copy link
Collaborator

@doanac doanac commented Sep 18, 2019

This is my stab at fixing #1292.

@codecov-io
Copy link

codecov-io commented Sep 18, 2019

Codecov Report

Merging #1370 into master will decrease coverage by 0.11%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1370      +/-   ##
==========================================
- Coverage   80.27%   80.16%   -0.12%     
==========================================
  Files         178      178              
  Lines       10567    10582      +15     
==========================================
  Hits         8483     8483              
- Misses       2084     2099      +15
Impacted Files Coverage Δ
src/libaktualizr/uptane/tuf.h 95.53% <100%> (+0.04%) ⬆️
src/libaktualizr/storage/sqlstorage.cc 76.89% <90.47%> (-0.33%) ⬇️
src/libaktualizr-posix/ipuptanesecondary.cc 82.66% <0%> (-4%) ⬇️
src/libaktualizr/package_manager/ostreemanager.cc 76.37% <0%> (-1.58%) ⬇️
src/aktualizr_primary/secondary.cc 82.89% <0%> (-1.32%) ⬇️
src/libaktualizr/crypto/keymanager.cc 88.74% <0%> (-0.67%) ⬇️
src/libaktualizr/primary/sotauptaneclient.cc 89.23% <0%> (-0.15%) ⬇️
src/aktualizr_lite/main.cc 76.59% <0%> (+0.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49d0da4...10c62c0. Read the comment docs.


ALTER TABLE installed_versions RENAME TO installed_versions_old;
CREATE TABLE installed_versions(id INTEGER PRIMARY KEY, ecu_serial TEXT NOT NULL, sha256 TEXT NOT NULL, name TEXT NOT NULL, hashes TEXT NOT NULL, length INTEGER NOT NULL DEFAULT 0, correlation_id TEXT NOT NULL DEFAULT '', is_current INTEGER NOT NULL CHECK (is_current IN (0,1)) DEFAULT 0, is_pending INTEGER NOT NULL CHECK (is_pending IN (0,1)) DEFAULT 0, was_installed INTEGER NOT NULL CHECK (was_installed IN (0,1)) DEFAULT 0, custom_meta TEXT NOT NULL DEFAULT "");
INSERT INTO installed_versions(ecu_serial, sha256, name, hashes, length, correlation_id, is_current, is_pending, was_installed) SELECT installed_versions_old.ecu_serial, installed_versions_old.sha256, installed_versions_old.name, installed_versions_old.hashes, installed_versions_old.length, installed_versions_old.correlation_id, installed_versions_old.is_current, installed_versions_old.is_pending, installed_versions_old.was_installed FROM installed_versions_old ORDER BY rowid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly order by id instead of rowid.

Also, it looks like a good use case for ALTER TABLE ADD COLUMN: https://sqlite.org/lang_altertable.html.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have sworn this was failing a migration test when I tried it yesterday. But I just changed to alter column did a clean build and it works. I did a force-push update and hopefully CI will be happy.

As more people take advantage of the custom dictionary value for
a Target, we'll need to keep track of this so things like package
managers can reason about things correctly.

Signed-off-by: Andy Doan <andy@foundries.io>
Signed-off-by: Andy Doan <andy@foundries.io>
Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, thanks!

@lbonn do you mind doing a final check as well before we merge, since you've worked with this code more closely and recently than me?

@lbonn
Copy link
Contributor

lbonn commented Sep 23, 2019

Sure, I've actually already taken a look and it seems fine on a correctness perspective.

@pattivacek pattivacek merged commit bb4722a into advancedtelematic:master Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants