Advertisement
buzzthedev

Ember SQL Database Setup

Apr 14th, 2024 (edited)
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 7.14 KB | None | 0 0
  1.   CREATE TABLE
  2.   public.panel_settings (
  3.     display_name text NOT NULL DEFAULT 'User'::text,
  4.     terms text NULL DEFAULT '<ul><li>No refunds given</li></ul>'::text,
  5.     id uuid NOT NULL DEFAULT gen_random_uuid (),
  6.     discord text NULL DEFAULT ''::text,
  7.     logo text NOT NULL DEFAULT '/default.svg'::text,
  8.     avatar_url text NULL DEFAULT '/logo.svg'::text,
  9.     created_at TIMESTAMP WITH TIME zone NULL DEFAULT now(),
  10.     api_key uuid NULL DEFAULT gen_random_uuid (),
  11.     api_uses_left SMALLINT NOT NULL DEFAULT '500'::SMALLINT,
  12.     license_active BOOLEAN NOT NULL DEFAULT FALSE,
  13.     subscription_id text NULL,
  14.     CONSTRAINT panel_settings_pkey PRIMARY KEY (id),
  15.     CONSTRAINT panel_settings_api_key_key UNIQUE (api_key),
  16.     CONSTRAINT panel_settings_discord_check CHECK ((LENGTH(discord) < 30)),
  17.     CONSTRAINT panel_settings_display_name_check CHECK ((LENGTH(display_name) < 100)),
  18.     CONSTRAINT panel_settings_logo_check CHECK ((LENGTH(logo) < 500)),
  19.     CONSTRAINT panel_settings_terms_check CHECK ((LENGTH(terms) < 500)),
  20.     CONSTRAINT panel_settings_uses_left_check CHECK ((api_uses_left < 5000)),
  21.     CONSTRAINT panel_settings_avatar_url_check CHECK ((LENGTH(avatar_url) < 1000))
  22.   ) tablespace pg_default;
  23.  
  24.   CREATE TABLE
  25.   public.panel_clients (
  26.     id uuid NOT NULL DEFAULT gen_random_uuid (),
  27.     created_at TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  28.     username text NOT NULL DEFAULT ''::text,
  29.     discord text NULL,
  30.     email text NULL,
  31.     avatar_url text NULL DEFAULT ''::text,
  32.     panel_id uuid NOT NULL DEFAULT auth.uid (),
  33.     password text NULL;
  34.     CONSTRAINT panel_clients_pkey PRIMARY KEY (id),
  35.     CONSTRAINT panel_clients_panel_id_fkey FOREIGN KEY (panel_id) REFERENCES panel_settings (id) ON UPDATE cascade ON DELETE cascade,
  36.     CONSTRAINT panel_clients_avatar_url_check CHECK ((LENGTH(avatar_url) < 10000)),
  37.     CONSTRAINT panel_clients_discord_check CHECK ((LENGTH(discord) < 30)),
  38.     CONSTRAINT panel_clients_email_check CHECK ((LENGTH(email) < 50)),
  39.     CONSTRAINT panel_clients_username_check CHECK ((LENGTH(username) < 30))
  40.   ) tablespace pg_default;
  41.  
  42.  
  43. CREATE TABLE
  44.   public.notifications (
  45.     id BIGINT generated BY DEFAULT AS IDENTITY,
  46.     created_at TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  47.     panel_id uuid NOT NULL DEFAULT auth.uid (),
  48.     title text NULL DEFAULT 'New notification'::text,
  49.     message text NULL,
  50.     subject uuid NULL DEFAULT gen_random_uuid (),
  51.     link text NOT NULL DEFAULT '/notifications'::text,
  52.     READ BOOLEAN NULL DEFAULT FALSE,
  53.     CONSTRAINT notifications_pkey PRIMARY KEY (id),
  54.     CONSTRAINT public_notifications_panel_id_fkey FOREIGN KEY (panel_id) REFERENCES panel_settings (id) ON UPDATE cascade ON DELETE cascade,
  55.     CONSTRAINT public_notifications_subject_fkey FOREIGN KEY (subject) REFERENCES panel_clients (id) ON UPDATE cascade ON DELETE cascade
  56.   ) tablespace pg_default;
  57.  
  58.   CREATE TABLE
  59.   public.products (
  60.     id BIGINT generated BY DEFAULT AS IDENTITY,
  61.     creator uuid NOT NULL DEFAULT auth.uid (),
  62.     description text NULL DEFAULT ''::text,
  63.     date_created TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  64.     CONSTRAINT products_pkey PRIMARY KEY (id),
  65.     CONSTRAINT products_creator_fkey FOREIGN KEY (creator) REFERENCES panel_settings (id) ON UPDATE cascade,
  66.     CONSTRAINT products_description_check CHECK ((LENGTH(description) < 36))
  67.   ) tablespace pg_default;
  68.  
  69.   CREATE TABLE
  70.   public.panel_commissions (
  71.     created_at TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  72.     title text NULL DEFAULT 'New commission'::text,
  73.     client uuid NULL,
  74.     total_value NUMERIC NULL DEFAULT 0.00,
  75.     total_paid NUMERIC NULL DEFAULT 0.00,
  76.     start_date TIMESTAMP WITH TIME zone NULL DEFAULT now(),
  77.     deadline TIMESTAMP WITH TIME zone NULL DEFAULT now(),
  78.     STATUS text NOT NULL DEFAULT 'not_started'::text,
  79.     id uuid NOT NULL DEFAULT gen_random_uuid (),
  80.     panel_id uuid NOT NULL DEFAULT auth.uid (),
  81.     tracking_id uuid NOT NULL DEFAULT gen_random_uuid (),
  82.     product BIGINT NULL,
  83.     pinned BOOLEAN NULL DEFAULT FALSE,
  84.     notes text NULL,
  85.     CONSTRAINT panel_commissions_pkey PRIMARY KEY (id),
  86.     CONSTRAINT panel_commissions_tracking_id_key UNIQUE (tracking_id),
  87.     CONSTRAINT panel_commissions_panel_id_fkey FOREIGN KEY (panel_id) REFERENCES panel_settings (id) ON UPDATE cascade ON DELETE cascade,
  88.     CONSTRAINT panel_commissions_client_fkey FOREIGN KEY (client) REFERENCES panel_clients (id) ON UPDATE cascade ON DELETE cascade,
  89.     CONSTRAINT panel_commissions_product_fkey FOREIGN KEY (product) REFERENCES products (id) ON UPDATE cascade ON DELETE RESTRICT,
  90.     CONSTRAINT panel_commissions_notes_check CHECK ((LENGTH(notes) < 1500)),
  91.     CONSTRAINT panel_commissions_status_check CHECK ((LENGTH(STATUS) < 20))
  92.   ) tablespace pg_default;
  93.  
  94.   CREATE TABLE
  95.   public.panel_quotes (
  96.     created_at TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  97.     title text NULL DEFAULT 'New quote'::text,
  98.     client uuid NULL,
  99.     proposed_amount INTEGER NULL DEFAULT 0,
  100.     start_date TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  101.     deadline TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  102.     payment_terms text NOT NULL DEFAULT 'custom'::text,
  103.     STATUS text NOT NULL DEFAULT 'pending'::text,
  104.     id uuid NOT NULL DEFAULT gen_random_uuid (),
  105.     panel_id uuid NOT NULL DEFAULT auth.uid (),
  106.     CONSTRAINT panel_quotes_pkey PRIMARY KEY (id),
  107.     CONSTRAINT panel_quotes_client_fkey FOREIGN KEY (client) REFERENCES panel_clients (id) ON UPDATE cascade ON DELETE cascade,
  108.     CONSTRAINT panel_quotes_panel_id_fkey FOREIGN KEY (panel_id) REFERENCES panel_settings (id) ON UPDATE cascade ON DELETE cascade,
  109.     CONSTRAINT panel_quotes_proposed_amount_check CHECK ((proposed_amount < 10000000))
  110.   ) tablespace pg_default;
  111.  
  112.   CREATE TABLE
  113.   public.panel_requests (
  114.     created_at TIMESTAMP WITH TIME zone NOT NULL DEFAULT now(),
  115.     description text NOT NULL,
  116.     offered_amount NUMERIC NULL DEFAULT 0.00,
  117.     deadline TIMESTAMP WITH TIME zone NULL,
  118.     STATUS text NOT NULL DEFAULT 'requested'::text,
  119.     id uuid NOT NULL DEFAULT gen_random_uuid (),
  120.     panel_id uuid NOT NULL DEFAULT auth.uid (),
  121.     commission uuid NULL,
  122.     paid BOOLEAN NOT NULL DEFAULT FALSE,
  123.     CONSTRAINT panel_requests_pkey PRIMARY KEY (id),
  124.     CONSTRAINT panel_requests_commission_fkey FOREIGN KEY (commission) REFERENCES panel_commissions (id) ON UPDATE cascade ON DELETE cascade,
  125.     CONSTRAINT panel_requests_panel_id_fkey FOREIGN KEY (panel_id) REFERENCES panel_settings (id) ON UPDATE cascade ON DELETE cascade,
  126.     CONSTRAINT panel_requests_description_check CHECK ((LENGTH(description) > 0)),
  127.     CONSTRAINT panel_requests_status_check CHECK ((LENGTH(STATUS) < 20))
  128.   ) tablespace pg_default;
  129.  
  130.   CREATE TABLE
  131.   public.panel_views (
  132.     id BIGINT generated BY DEFAULT AS IDENTITY,
  133.     DATA json NOT NULL,
  134.     panel_id uuid NULL DEFAULT auth.uid (),
  135.     name text NOT NULL DEFAULT 'New view'::text,
  136.     CONSTRAINT panel_views_pkey PRIMARY KEY (id),
  137.     CONSTRAINT panel_views_panel_id_fkey FOREIGN KEY (panel_id) REFERENCES panel_settings (id) ON UPDATE cascade ON DELETE cascade,
  138.     CONSTRAINT panel_views_name_check CHECK ((LENGTH(name) < 30))
  139.   ) tablespace pg_default;
  140.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement