From 6977c78476e55b4e5d44d65aaf288c0ea37619f2 Mon Sep 17 00:00:00 2001 From: Rachid F Date: Wed, 1 May 2024 14:22:03 -0700 Subject: [PATCH] :card_file_box: Added project ID to EAV Attribute table --- packages/api/scripts/init.sql | 79 ++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/packages/api/scripts/init.sql b/packages/api/scripts/init.sql index 9cb143fc2..8f5d2e92c 100644 --- a/packages/api/scripts/init.sql +++ b/packages/api/scripts/init.sql @@ -1,7 +1,3 @@ --- ************************* SqlDBM: PostgreSQL ************************* --- *********** Generated by SqlDBM: Panora_DB by rf@panora.dev ********** - - -- ************************************** webhooks_reponses @@ -74,10 +70,11 @@ CREATE TABLE users 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 ), - CONSTRAINT unique_email UNIQUE ( email ) + CONSTRAINT force_stytch_id_unique UNIQUE ( id_stytch ) ); @@ -89,6 +86,7 @@ STYTCH_B2B STYTCH_B2C'; COMMENT ON COLUMN users.created_at IS 'DEFAULT NOW() to automatically insert a value if nothing supplied'; +COMMENT ON CONSTRAINT force_stytch_id_unique ON users IS 'force unique on stytch id'; @@ -224,21 +222,22 @@ COMMENT ON COLUMN entity.ressource_owner_id IS 'uuid of the ressource owner - ca --- ************************************** connection_strategies -CREATE TABLE connection_strategies + +-- ************************************** cs_values + +CREATE TABLE cs_values ( - id_connection_strategy uuid NOT NULL, - status boolean NOT NULL, - type text NOT NULL, - id_project uuid NULL, - CONSTRAINT PK_connection_strategies PRIMARY KEY ( id_connection_strategy ) + id_cs_value uuid NOT NULL, + value text NOT NULL, + id_cs_attribute uuid NOT NULL, + CONSTRAINT PK_ct_values PRIMARY KEY ( id_cs_value ) ); -COMMENT ON COLUMN connection_strategies.status IS 'if the connection strategy should overwrite default strategy (from env)'; -COMMENT ON COLUMN connection_strategies.type IS 'OAUTH2, API_KEY, PIPEDRIVE_CLOUD_OAUTH, PIPEDRIVE_CLOUD_API, HUBSPOT_CLOUD'; + + @@ -248,11 +247,16 @@ CREATE TABLE cs_entities ( id_cs_entity uuid NOT NULL, id_connection_strategy uuid NOT NULL, - CONSTRAINT PK_ct_entities PRIMARY KEY ( id_cs_entity ), - CONSTRAINT FK_cs_id FOREIGN KEY ( id_connection_strategy ) REFERENCES connection_strategies ( id_connection_strategy ) + CONSTRAINT PK_ct_entities PRIMARY KEY ( id_cs_entity ) ); + + + + + + -- ************************************** cs_attributes CREATE TABLE cs_attributes @@ -261,21 +265,13 @@ CREATE TABLE cs_attributes attribute_slug text NOT NULL, data_type text NOT NULL, id_cs_entity uuid NOT NULL, - CONSTRAINT PK_ct_attributes PRIMARY KEY ( id_cs_attribute ), - CONSTRAINT FK_cs_entity FOREIGN KEY ( id_cs_entity ) REFERENCES cs_entities ( id_cs_entity ) + CONSTRAINT PK_ct_attributes PRIMARY KEY ( id_cs_attribute ) ); --- ************************************** cs_values -CREATE TABLE cs_values -( - id_cs_value uuid NOT NULL, - value text NOT NULL, - id_cs_attribute uuid NOT NULL, - CONSTRAINT PK_ct_values PRIMARY KEY ( id_cs_value ), - CONSTRAINT FK_cs_attribute FOREIGN KEY ( id_cs_attribute ) REFERENCES cs_attributes ( id_cs_attribute ) -); + + @@ -316,6 +312,32 @@ CREATE TABLE crm_deals_stages ); + + + + + + +-- ************************************** connection_strategies + +CREATE TABLE connection_strategies +( + id_connection_strategy uuid NOT NULL, + status boolean NOT NULL, + type text NOT NULL, + id_project uuid NULL, + CONSTRAINT PK_connection_strategies PRIMARY KEY ( id_connection_strategy ) +); + + + +COMMENT ON COLUMN connection_strategies.status IS 'if the connection strategy should overwrite default strategy (from env)'; +COMMENT ON COLUMN connection_strategies.type IS 'OAUTH2, API_KEY, PIPEDRIVE_CLOUD_OAUTH, PIPEDRIVE_CLOUD_API, HUBSPOT_CLOUD'; + + + + + -- ************************************** tcg_tickets CREATE TABLE tcg_tickets @@ -490,6 +512,7 @@ CREATE TABLE attribute remote_id text NOT NULL, "source" text NOT NULL, id_entity uuid NULL, + id_project uuid NOT NULL, "scope" text NOT NULL, id_consumer uuid NULL, CONSTRAINT PK_attribute PRIMARY KEY ( id_attribute ), @@ -1112,6 +1135,7 @@ CREATE TABLE connections id_connection uuid NOT NULL, status text NOT NULL, provider_slug text NOT NULL, + vertical text NOT NULL, account_url text NULL, token_type text NOT NULL, access_token text NULL, @@ -1119,7 +1143,6 @@ CREATE TABLE connections expiration_timestamp timestamp NULL, created_at timestamp NOT NULL, connection_token text NULL, - vertical text NOT NULL, id_project uuid NOT NULL, id_linked_user uuid NOT NULL, CONSTRAINT PK_connections PRIMARY KEY ( id_connection ),