-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: PRO-2395 sponsorship policy db migration
- Loading branch information
1 parent
b4ec24b
commit df5476a
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-------------------------------------------------------------------------------- | ||
-- Up | ||
-------------------------------------------------------------------------------- | ||
|
||
-- Create POLICIES Table | ||
CREATE TABLE IF NOT EXISTS policies ( | ||
POLICY_ID INTEGER PRIMARY KEY, | ||
WALLET_ADDRESS TEXT NOT NULL, | ||
NAME TEXT NOT NULL, | ||
DESCRIPTION TEXT, | ||
START_DATE DATE, | ||
END_DATE DATE, | ||
IS_PERPETUAL BOOLEAN DEFAULT FALSE, | ||
IS_UNIVERSAL BOOLEAN DEFAULT FALSE, | ||
CONTRACT_RESTRICTIONS TEXT, -- Stores JSON string because SQLite doesn't support JSON natively | ||
FOREIGN KEY (WALLET_ADDRESS) REFERENCES api_keys(WALLET_ADDRESS) | ||
); | ||
|
||
-- Create POLICY_LIMITS Table | ||
CREATE TABLE IF NOT EXISTS policy_limits ( | ||
LIMIT_ID INTEGER PRIMARY KEY, | ||
POLICY_ID INTEGER NOT NULL, | ||
LIMIT_TYPE TEXT NOT NULL, | ||
MAX_USD REAL, -- REAL used in SQLite for floating-point numbers | ||
MAX_ETH REAL, | ||
MAX_OPERATIONS INTEGER, | ||
FOREIGN KEY (POLICY_ID) REFERENCES policies(POLICY_ID) | ||
); | ||
|
||
-- Create POLICY_CHAINS Table | ||
CREATE TABLE IF NOT EXISTS policy_chains ( | ||
POLICY_CHAIN_ID INTEGER PRIMARY KEY, | ||
POLICY_ID INTEGER NOT NULL, | ||
CHAIN_NAME TEXT NOT NULL, | ||
FOREIGN KEY (POLICY_ID) REFERENCES policies(POLICY_ID) | ||
); | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
-- Down | ||
-------------------------------------------------------------------------------- | ||
|
||
DROP TABLE IF EXISTS policy_chains; | ||
DROP TABLE IF EXISTS policy_limits; | ||
DROP TABLE IF EXISTS policies; |