Skip to content

Commit

Permalink
Merge pull request #339 from panoratech/db_collections
Browse files Browse the repository at this point in the history
🗃️ Added Collections
  • Loading branch information
rflihxyz authored Mar 31, 2024
2 parents 987d30e + c4dce84 commit 44c4f16
Showing 1 changed file with 68 additions and 66 deletions.
134 changes: 68 additions & 66 deletions packages/api/scripts/init.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

-- ************************************** webhooks_reponses

CREATE TABLE webhooks_reponses
Expand Down Expand Up @@ -42,7 +43,7 @@ CREATE TABLE webhook_endpoints
secret text NOT NULL,
active boolean NOT NULL,
created_at timestamp NOT NULL,
"scope" text[] NULL,
"scope" text[] NULL,
id_project uuid NOT NULL,
last_update timestamp NULL,
CONSTRAINT PK_webhook_endpoint PRIMARY KEY ( id_webhook_endpoint )
Expand All @@ -59,6 +60,35 @@ COMMENT ON COLUMN webhook_endpoints."scope" IS 'stringified array with events,';



-- ************************************** users

CREATE TABLE users
(
id_user uuid NOT NULL,
identification_strategy text NOT NULL,
email text NULL,
password_hash text NULL,
first_name text NOT NULL,
last_name text NOT NULL,
id_stytch text NULL,
created_at timestamp NOT NULL DEFAULT NOW(),
modified_at timestamp NOT NULL DEFAULT NOW(),
CONSTRAINT PK_users PRIMARY KEY ( id_user )
);



COMMENT ON COLUMN users.identification_strategy IS 'can be:
PANORA_SELF_HOSTED
STYTCH_B2B
STYTCH_B2C';
COMMENT ON COLUMN users.created_at IS 'DEFAULT NOW() to automatically insert a value if nothing supplied';





-- ************************************** tcg_users

CREATE TABLE tcg_users
Expand Down Expand Up @@ -105,6 +135,28 @@ CREATE TABLE tcg_teams



-- ************************************** tcg_collections

CREATE TABLE tcg_collections
(
id_tcg_collection uuid NOT NULL,
name text NULL,
description text NULL,
remote_id text NULL,
collection_type text NULL,
parent_collection uuid NULL,
created_at timestamp NOT NULL,
modified_at timestamp NOT NULL,
CONSTRAINT PK_tcg_collections PRIMARY KEY ( id_tcg_collection )
);








-- ************************************** tcg_accounts

CREATE TABLE tcg_accounts
Expand Down Expand Up @@ -134,7 +186,7 @@ CREATE TABLE remote_data
(
id_remote_data uuid NOT NULL,
ressource_owner_id uuid NULL,
"format" text NULL,
"format" text NULL,
data text NULL,
created_at timestamp NULL,
CONSTRAINT PK_remote_data PRIMARY KEY ( id_remote_data ),
Expand All @@ -150,23 +202,6 @@ COMMENT ON COLUMN remote_data."format" IS 'can be json, xml';



-- ************************************** organizations

CREATE TABLE organizations
(
id_organization uuid NOT NULL,
name text NOT NULL,
stripe_customer_id text NOT NULL,
CONSTRAINT PK_organizations PRIMARY KEY ( id_organization )
);








-- ************************************** entity

CREATE TABLE entity
Expand Down Expand Up @@ -227,35 +262,6 @@ CREATE TABLE crm_deals_stages



-- ************************************** users

CREATE TABLE users
(
id_user uuid NOT NULL,
email text NOT NULL,
password_hash text NOT NULL,
first_name text NOT NULL,
last_name text NOT NULL,
created_at timestamp NOT NULL DEFAULT NOW(),
modified_at timestamp NOT NULL DEFAULT NOW(),
id_organization uuid NULL,
CONSTRAINT PK_users PRIMARY KEY ( id_user ),
CONSTRAINT FK_5 FOREIGN KEY ( id_organization ) REFERENCES organizations ( id_organization )
);

CREATE INDEX FK_1_users ON users
(
id_organization
);



COMMENT ON COLUMN users.created_at IS 'DEFAULT NOW() to automatically insert a value if nothing supplied';





-- ************************************** tcg_tickets

CREATE TABLE tcg_tickets
Expand All @@ -268,6 +274,7 @@ CREATE TABLE tcg_tickets
ticket_type text NULL,
parent_ticket uuid NULL,
tags text[] NULL,
collections text[] NULL,
completed_at timestamp NULL,
priority text NULL,
created_at timestamp NOT NULL,
Expand Down Expand Up @@ -335,19 +342,14 @@ CREATE INDEX FK_tcg_contact_tcg_account_id ON tcg_contacts

CREATE TABLE projects
(
id_project uuid NOT NULL,
name text NOT NULL,
id_organization uuid NOT NULL,
sync_mode text NOT NULL,
pull_frequency bigint NULL,
redirect_url text NULL,
id_project uuid NOT NULL,
name text NOT NULL,
sync_mode text NOT NULL,
pull_frequency bigint NULL,
redirect_url text NULL,
id_user uuid NOT NULL,
CONSTRAINT PK_projects PRIMARY KEY ( id_project ),
CONSTRAINT FK_6 FOREIGN KEY ( id_organization ) REFERENCES organizations ( id_organization )
);

CREATE INDEX FK_1_projects ON projects
(
id_organization
CONSTRAINT FK_46_1 FOREIGN KEY ( id_user ) REFERENCES users ( id_user )
);


Expand Down Expand Up @@ -432,9 +434,9 @@ CREATE TABLE attribute
description text NOT NULL,
data_type text NOT NULL,
remote_id text NOT NULL,
"source" text NOT NULL,
"source" text NOT NULL,
id_entity uuid NULL,
"scope" text NOT NULL,
"scope" text NOT NULL,
id_consumer uuid NULL,
CONSTRAINT PK_attribute PRIMARY KEY ( id_attribute ),
CONSTRAINT FK_32 FOREIGN KEY ( id_entity ) REFERENCES entity ( id_entity )
Expand Down Expand Up @@ -765,7 +767,7 @@ CREATE TABLE crm_addresses
street_1 text NULL,
street_2 text NULL,
city text NULL,
"state" text NULL,
"state" text NULL,
postal_code text NULL,
country text NULL,
address_type text NULL,
Expand Down Expand Up @@ -904,7 +906,7 @@ CREATE TABLE events
status text NOT NULL,
type text NOT NULL,
direction text NOT NULL,
"timestamp" timestamp NOT NULL DEFAULT NOW(),
"timestamp" timestamp NOT NULL DEFAULT NOW(),
method text NOT NULL,
url text NOT NULL,
provider text NOT NULL,
Expand Down Expand Up @@ -1096,7 +1098,7 @@ COMMENT ON COLUMN connections.connection_token IS 'Connection token users will p
CREATE TABLE webhook_delivery_attempts
(
id_webhook_delivery_attempt uuid NOT NULL,
"timestamp" timestamp NOT NULL,
"timestamp" timestamp NOT NULL,
status text NOT NULL,
next_retry timestamp NULL,
attempt_count bigint NOT NULL,
Expand Down Expand Up @@ -1151,7 +1153,7 @@ can be 0 1 2 3 4 5 6';
CREATE TABLE jobs_status_history
(
id_jobs_status_history uuid NOT NULL,
"timestamp" timestamp NOT NULL DEFAULT NOW(),
"timestamp" timestamp NOT NULL DEFAULT NOW(),
previous_status text NOT NULL,
new_status text NOT NULL,
id_event uuid NOT NULL,
Expand Down

1 comment on commit 44c4f16

@vercel
Copy link

@vercel vercel bot commented on 44c4f16 Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.