Skip to content

Commit

Permalink
Merge pull request #20 from rarimo/fix/migrations
Browse files Browse the repository at this point in the history
Fix migrations
  • Loading branch information
violog authored May 27, 2024
2 parents 38ae980 + fce64a0 commit 5d6bf2c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/assets/migrations/001_initial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CREATE TABLE IF NOT EXISTS balances

CREATE INDEX IF NOT EXISTS balances_page_index ON balances (amount, updated_at) WHERE referred_by IS NOT NULL;

DROP TRIGGER IF EXISTS set_updated_at ON balances;
CREATE TRIGGER set_updated_at
BEFORE UPDATE
ON balances
Expand All @@ -31,6 +32,7 @@ CREATE TABLE IF NOT EXISTS referrals
ALTER TABLE balances ADD CONSTRAINT referred_by_fk FOREIGN KEY (referred_by) REFERENCES referrals (id);
CREATE INDEX IF NOT EXISTS referrals_nullifier_index ON referrals (nullifier);

DROP TYPE IF EXISTS event_status;
CREATE TYPE event_status AS ENUM ('open', 'fulfilled', 'claimed');

CREATE TABLE IF NOT EXISTS events
Expand All @@ -49,6 +51,7 @@ CREATE TABLE IF NOT EXISTS events

CREATE INDEX IF NOT EXISTS events_page_index ON events (nullifier, updated_at);

DROP TRIGGER IF EXISTS set_updated_at ON events;
CREATE TRIGGER set_updated_at
BEFORE UPDATE
ON events
Expand Down

0 comments on commit 5d6bf2c

Please sign in to comment.