Commit graph

14 commits

Author SHA1 Message Date
Viktor Torstensson
4ccb56a771
multi: add UpdateAccountAliasForTests query
In the upcoming kvdb to SQL migration of the actions store, we need to
simulate in tests that two or more accounts have colliding account
aliases for the first 4 bytes of the alias. In order to allow creation
of such accounts, we need to be able to update the alias of an account
in tests, and this commit adds the a SQL query enabling this
functionality.

Note that the `UpdateAccountAliasForTests` query is only intended for
use in tests and should not be used in production code.
2025-10-07 02:13:41 +02:00
Viktor Torstensson
5d8f03e241
sqlc+firewalldb: add GetAction SQL query
Add a new SQL query `GetAction` to retrieve a single action by its ID.
This query will be needed for the kvdb to SQL migration of actions
store.
2025-10-07 02:13:14 +02:00
Viktor Tigerström
75f6137d80
multi: rename sql kvstores session_id to group_id
Rename the session_id to group_id in kvstores table in the SQL store, to
better represent how the field is actually used.

Note that this is a breaking change, and would normally require a new
migration. But as the SQL store is not used in production, and only
enabled under the dev build flag, we can rename it without a new
migration, as there's no users of the SQL store in production.
2025-07-21 14:45:45 +02:00
Viktor Tigerström
f84e24491b
db: add List All Kv Records query
During the upcoming upcoming migration of the firewall database to SQL,
we need to be able to check all kvstores records in the SQL database,
to validate that the migration is successful in tests.

This commits adds a query to list all kvstores records, which enables
that functionality.
2025-07-21 14:45:45 +02:00
Elle Mouton
1674490ab5
db: define manual action SQL queries
Here, we manually define some queries for the actions store. We do this
so that we can manually build the "SELECT" and only add "WHERE" clauses
that are actually needed for the query and hence ensure that available
indexes are used.
2025-05-30 10:54:34 +02:00
Elle Mouton
65e4309f9c
db: add actions schemas and queries
In this commit we define the schema for the `actions` table along with
various queries we will need for interacting with the table. NOTE: we
will also add some of our own queries manually in commits to follow.
2025-05-29 07:04:40 +02:00
Viktor Tigerström
6030f650fd
db: order ListAllAccounts result by account id.
In preparation for the migration from kvdb to SQL, we update the results
of the ListAllAccounts query. After the migration has been implemented,
we will test that the result off all accounts in the SQL database
is the same as the result of the fetching all accounts in the kvdb.

By ordering the SQL query's result by account id, we ensure that all
accounts are returned in the same order as they are returned by the
kvdb.
2025-05-15 17:08:48 +02:00
Elle Mouton
a54accbf78
db/sqlc: priv map schemas and crud
Define the privacy mapper schemas and queries.
2025-04-22 06:10:48 +02:00
Elle Mouton
e8d72f7276
db/sqlc: kvstores schemas & queries
In this commit, we define the schemas and queries that are needed to
implement the firewalldb's KVStores in SQL.
2025-04-10 13:03:20 +02:00
Elle
64ab73a763
Merge pull request #994 from ellemouton/sql21Sessions13
[sql-21] sessions: SQL schemas & queries
2025-03-11 12:14:30 -05:00
Elle Mouton
20167666ad
db/sqlc: add session schemas and queries
This commit adds all the schema definitions we require for the sessions
store.
2025-03-11 11:37:41 -05:00
Elle Mouton
a8d3c1ac7e
db/sqlc: only use named UNIQUE indices
Replace any named UNIQUE indices in the accounts tables and replace with
named ones. This is for a future where we want to be able to edit these
indices without having to drop the table.
It is fine for us to just edit these tables since these are not
available in "prod" yet.
2025-03-10 13:54:11 -05:00
Elle Mouton
d3db19e2cc
db: SQL boilerplate code
This commit adds the boilerplate code we will need in order to start
using SQL backed stores (namely sqlite and postgres) for our DB backend.

NOTE that this has been copied from the taproot-assets repo.
2025-01-29 16:37:20 +02:00
Elle Mouton
caec0742db
db/sqlc: add account related tables and queries
This commit also contains the sqlc.yaml file, the `make sqlc` command
and the script for generating sqlc code. This must be done in this
commit as the script only works if there are queries to generate from.
2025-01-29 16:37:20 +02:00