Skip to content

Commit

Permalink
feat: PRO-2395 sponsorship policy db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kanthgithub committed Jun 6, 2024
1 parent b4ec24b commit df5476a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions backend/src/migrations/003.sponsorship-policy.sql
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;

0 comments on commit df5476a

Please sign in to comment.