Advertisement
buzzthedev

Untitled

Sep 30th, 2024 (edited)
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PostgreSQL 8.24 KB | Software | 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.     settings JSONB DEFAULT '{"currency_prefix": "$"}',
  15.     psk TEXT,
  16.     sk TEXT,
  17.     constraint panel_settings_pkey primary key (id),
  18.     constraint panel_settings_api_key_key unique (api_key),
  19.     constraint panel_settings_discord_check check ((length(discord) < 30)),
  20.     constraint panel_settings_display_name_check check ((length(display_name) < 100)),
  21.     constraint panel_settings_logo_check check ((length(logo) < 500)),
  22.     constraint panel_settings_terms_check check ((length(terms) < 500)),
  23.     constraint panel_settings_uses_left_check check ((api_uses_left < 5000)),
  24.     constraint panel_settings_avatar_url_check check ((length(avatar_url) < 1000))
  25.   ) tablespace pg_default;
  26.  
  27. create table
  28.   public.panel_clients (
  29.     id uuid not null default gen_random_uuid (),
  30.     created_at timestamp with time zone not null default now(),
  31.     username text not null default ''::text,
  32.     discord text null,
  33.     email text null,
  34.     password text null,
  35.     avatar_url text null default ''::text,
  36.     panel_id uuid not null default auth.uid (),
  37.     stripe_id text null,
  38.     constraint panel_clients_pkey primary key (id),
  39.     constraint panel_clients_panel_id_fkey foreign key (panel_id) references panel_settings (id) on update cascade on delete cascade,
  40.     constraint panel_clients_avatar_url_check check ((length(avatar_url) < 10000)),
  41.     constraint panel_clients_discord_check check ((length(discord) < 30)),
  42.     constraint panel_clients_email_check check ((length(email) < 50)),
  43.     constraint panel_clients_username_check check ((length(username) < 30))
  44.   ) tablespace pg_default;
  45.  
  46. create table
  47.   public.notifications (
  48.     id bigint generated by default as identity,
  49.     created_at timestamp with time zone not null default now(),
  50.     panel_id uuid not null default auth.uid (),
  51.     title text null default 'New notification'::text,
  52.     message text null,
  53.     subject uuid null default gen_random_uuid (),
  54.     link text not null default '/notifications'::text,
  55.     read boolean null default false,
  56.     constraint notifications_pkey primary key (id),
  57.     constraint public_notifications_panel_id_fkey foreign key (panel_id) references panel_settings (id) on update cascade on delete cascade,
  58.     constraint public_notifications_subject_fkey foreign key (subject) references panel_clients (id) on update cascade on delete cascade
  59.   ) tablespace pg_default;
  60.  
  61. create table
  62.   public.products (
  63.     id bigint generated by default as identity,
  64.     creator uuid not null default auth.uid (),
  65.     description text null default ''::text,
  66.     date_created timestamp with time zone not null default now(),
  67.     constraint products_pkey primary key (id),
  68.     constraint products_creator_fkey foreign key (creator) references panel_settings (id) on update cascade,
  69.     constraint products_description_check check ((length(description) < 36))
  70.   ) tablespace pg_default;
  71.  
  72. create table
  73.   public.panel_commissions (
  74.     created_at timestamp with time zone not null default now(),
  75.     title text null default 'New commission'::text,
  76.     client uuid null,
  77.     total_value numeric null default 0.00,
  78.     total_paid numeric null default 0.00,
  79.     start_date timestamp with time zone null default now(),
  80.     deadline timestamp with time zone null default now(),
  81.     status text not null default 'not_started'::text,
  82.     id uuid not null default gen_random_uuid (),
  83.     panel_id uuid not null default auth.uid (),
  84.     tracking_id uuid not null default gen_random_uuid (),
  85.     product bigint null,
  86.     pinned boolean null default false,
  87.     notes text null,
  88.     constraint panel_commissions_pkey primary key (id),
  89.     constraint panel_commissions_tracking_id_key unique (tracking_id),
  90.     constraint panel_commissions_panel_id_fkey foreign key (panel_id) references panel_settings (id) on update cascade on delete cascade,
  91.     constraint panel_commissions_client_fkey foreign key (client) references panel_clients (id) on update cascade on delete cascade,
  92.     constraint panel_commissions_product_fkey foreign key (product) references products (id) on update cascade on delete restrict,
  93.     constraint panel_commissions_notes_check check ((length(notes) < 1500)),
  94.     constraint panel_commissions_status_check check ((length(status) < 20))
  95.   ) tablespace pg_default;
  96.  
  97. create table
  98.   public.panel_quotes (
  99.     created_at timestamp with time zone not null default now(),
  100.     title text null default 'New quote'::text,
  101.     client uuid null,
  102.     proposed_amount integer null default 0,
  103.     start_date timestamp with time zone not null default now(),
  104.     deadline timestamp with time zone not null default now(),
  105.     payment_terms text not null default 'custom'::text,
  106.     status text not null default 'pending'::text,
  107.     id uuid not null default gen_random_uuid (),
  108.     panel_id uuid not null default auth.uid (),
  109.     constraint panel_quotes_pkey primary key (id),
  110.     constraint panel_quotes_client_fkey foreign key (client) references panel_clients (id) on update cascade on delete cascade,
  111.     constraint panel_quotes_panel_id_fkey foreign key (panel_id) references panel_settings (id) on update cascade on delete cascade,
  112.     constraint panel_quotes_proposed_amount_check check ((proposed_amount < 10000000))
  113.   ) tablespace pg_default;
  114.  
  115. create table
  116.   public.panel_requests (
  117.     created_at timestamp with time zone not null default now(),
  118.     description text not null,
  119.     offered_amount numeric null default 0.00,
  120.     deadline timestamp with time zone null,
  121.     status text not null default 'requested'::text,
  122.     id uuid not null default gen_random_uuid (),
  123.     panel_id uuid not null default auth.uid (),
  124.     commission uuid null,
  125.     paid boolean not null default false,
  126.     constraint panel_requests_pkey primary key (id),
  127.     constraint panel_requests_commission_fkey foreign key (commission) references panel_commissions (id) on update cascade on delete cascade,
  128.     constraint panel_requests_panel_id_fkey foreign key (panel_id) references panel_settings (id) on update cascade on delete cascade,
  129.     constraint panel_requests_description_check check ((length(description) > 0)),
  130.     constraint panel_requests_status_check check ((length(status) < 20))
  131.   ) tablespace pg_default;
  132.  
  133. create table
  134.   public.panel_views (
  135.     id bigint generated by default as identity,
  136.     data json not null,
  137.     panel_id uuid null default auth.uid (),
  138.     name text not null default 'New view'::text,
  139.     constraint panel_views_pkey primary key (id),
  140.     constraint panel_views_panel_id_fkey foreign key (panel_id) references panel_settings (id) on update cascade on delete cascade,
  141.     constraint panel_views_name_check check ((length(name) < 30))
  142.   ) tablespace pg_default;
  143.  
  144. create table
  145.   public.panel_invoices (
  146.     created_at timestamp with time zone not null default now(),
  147.     amount real null default '0'::real,
  148.     link text null,
  149.     paid_at timestamp with time zone null,
  150.     client uuid null,
  151.     title text null,
  152.     pinned boolean null default false,
  153.     panel_id uuid null default auth.uid (),
  154.     id uuid not null default gen_random_uuid (),
  155.     due_date timestamp with time zone null,
  156.     status text null default 'unpaid'::text,
  157.     stripe_invoice_id text null,
  158.     memo text null,
  159.     type TEXT,
  160.     commission UUID,
  161.     constraint panel_invoices_pkey primary key (id),
  162.     constraint panel_invoices_id_key unique (id),
  163.     constraint panel_invoices_client_fkey foreign key (client) references panel_clients (id),
  164.     constraint panel_invoices_panel_id_fkey foreign key (panel_id) references panel_settings (id) on update cascade on delete cascade,
  165.     constraint fk_commission foreign key (commission) references panel_commissions (id)
  166.   ) tablespace pg_default;
  167.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement