repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

pico / sql / migrations
Eric Bower · 25 Jan 24

20240120_add_payment_history.sql

 1CREATE TABLE IF NOT EXISTS payment_history (
 2  id uuid NOT NULL DEFAULT uuid_generate_v4(),
 3  user_id uuid,
 4  amount bigint NOT NULL,
 5  payment_type character varying(50),
 6  data jsonb NOT NULL DEFAULT '{"notes": ""}'::jsonb,
 7  created_at timestamp without time zone NOT NULL DEFAULT NOW(),
 8  CONSTRAINT payment_history_aliases_pkey PRIMARY KEY (id),
 9  CONSTRAINT fk_payment_history_users
10    FOREIGN KEY(user_id)
11  REFERENCES app_users(id)
12);
13
14ALTER TABLE feature_flags DROP CONSTRAINT user_features_unique_name;
15ALTER TABLE feature_flags ADD COLUMN expires_at timestamp without time zone
16  NOT NULL DEFAULT NOW() + '1 year'::interval;
17ALTER TABLE feature_flags ADD COLUMN data jsonb
18  NOT NULL DEFAULT '{}'::jsonb;
19ALTER TABLE feature_flags ADD COLUMN payment_history_id uuid;
20ALTER TABLE feature_flags ADD CONSTRAINT fk_features_payment_history
21    FOREIGN KEY(payment_history_id)
22  REFERENCES payment_history(id)
23  ON DELETE CASCADE
24  ON UPDATE CASCADE;