Skip to content

[sql-33] session: add migration code from kvdb to SQL #1051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ViktorTigerstrom
Copy link
Contributor

This PR introduces the migration logic for transitioning the sessions store from kvdb to SQL.

Note that as of this PR, the migration is not yet triggered by any production code, i.e. only tests execute the migration logic.

Part of #917

In preparation for upcoming migration tests from a kvdb to an SQL store,
this commit updates the NewTestDB function to return the Store interface
rather than a concrete store implementation.

This change ensures that migration tests can call NewTestDB under any
build tag while receiving a consistent return type.
In preparation for migrating sessions to the new SQLstore, we need to
expose db.BaseDB in the SQLstore. Therefore we change the SQLstore
to embed the BaseDB interface, rather than the concrete *sql.DB type.
When a session has a MacaroonRecipe set, which has a nil value set for
either the `Permissions` or the `Caveats` field, the kvdb session store
would return that field as nil, while the sql prior to this commit
would return an empty array.

When the we migrate the session store from kvdb to sql, that will cause
the kvdb and the migrate session store to differ when comparing them,
which will cause the migration to fail.

This commit fixes that by ensuring that the sql session store returns
a nil value for those fields in that scenario, rather than an empty
array.
@ViktorTigerstrom ViktorTigerstrom added the no-changelog This PR is does not require a release notes entry label Apr 29, 2025
This commit introduces the migration logic for transitioning the
sessions store from kvdb to SQL.

Note that as of this commit, the migration is not yet triggered by any
production code, i.e. only tests execute the migration logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog This PR is does not require a release notes entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant