Skip to content

[sql-41] firewalldb: add migration code for kvstores from kvdb to SQL #1079

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 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 82 additions & 46 deletions db/sqlc/kvstores.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions db/sqlc/migrations/000003_kvstores.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS features (
CREATE UNIQUE INDEX IF NOT EXISTS features_name_idx ON features (name);

-- kvstores houses key-value pairs under various namespaces determined
-- by the rule name, session ID, and feature name.
-- by the rule name, group ID, and feature name.
CREATE TABLE IF NOT EXISTS kvstores (
-- The auto incrementing primary key.
id INTEGER PRIMARY KEY,
Expand All @@ -35,15 +35,15 @@ CREATE TABLE IF NOT EXISTS kvstores (
-- kv_store.
rule_id BIGINT REFERENCES rules(id) NOT NULL,

-- The session ID that this kv_store belongs to.
-- If this is set, then this kv_store is a session-specific
-- The group ID that this kv_store belongs to.
-- If this is set, then this kv_store is a session-group specific
-- kv_store for the given rule.
session_id BIGINT REFERENCES sessions(id) ON DELETE CASCADE,
group_id BIGINT REFERENCES sessions(id) ON DELETE CASCADE,

-- The feature name that this kv_store belongs to.
-- If this is set, then this kv_store is a feature-specific
-- kvstore under the given session ID and rule name.
-- If this is set, then session_id must also be set.
-- kvstore under the given group ID and rule name.
-- If this is set, then group_id must also be set.
feature_id BIGINT REFERENCES features(id),

-- The key of the entry.
Expand All @@ -54,4 +54,4 @@ CREATE TABLE IF NOT EXISTS kvstores (
);

CREATE UNIQUE INDEX IF NOT EXISTS kvstores_lookup_idx
ON kvstores (entry_key, rule_id, perm, session_id, feature_id);
ON kvstores (entry_key, rule_id, perm, group_id, feature_id);
2 changes: 1 addition & 1 deletion db/sqlc/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions db/sqlc/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading