Skip to content

Commit

Permalink
Merge pull request #408 from panoratech/add-projectID-table-attribute
Browse files Browse the repository at this point in the history
🗃️ Added project ID to EAV Attribute table
  • Loading branch information
rflihxyz authored May 1, 2024
2 parents 1c66632 + 6977c78 commit 7031826
Showing 1 changed file with 51 additions and 28 deletions.
79 changes: 51 additions & 28 deletions packages/api/scripts/init.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- ************************* SqlDBM: PostgreSQL *************************
-- *********** Generated by SqlDBM: Panora_DB by [email protected] **********



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

Expand Down Expand Up @@ -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 )
);


Expand All @@ -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';



Expand Down Expand Up @@ -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';





Expand All @@ -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
Expand All @@ -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 )
);





Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ),
Expand Down Expand Up @@ -1112,14 +1135,14 @@ 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,
refresh_token text NULL,
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 ),
Expand Down

0 comments on commit 7031826

Please sign in to comment.