Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗃️ Added project ID to EAV Attribute table #408

Merged
merged 1 commit into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 lines +229 to +234
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Several files in the codebase still use the old table and column names from connection_strategies. Here are the specific locations that need attention:

  • packages/api/scripts/init.sql: References to connection_strategies, id_connection_strategy, status, and type are found in multiple places within this file.

Please ensure that all these references are updated to reflect the new table name cs_values and the new column names to prevent runtime errors.

Analysis chain

The renaming of the table and columns in cs_values is consistent with the summary. Ensure that all references to these columns and the table are updated across the application to prevent runtime errors.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all references to the old `connection_strategies` table and its columns are updated to `cs_values` and the new column names.

# Find files that might contain old references.
rg --files-with-matches --type sql $'connection_strategies|id_connection_strategy|status|type' | while read file; do
  # Test: Search for the old table and column names to find omissions. Expect: No matches.
  rg '(connection_strategies|id_connection_strategy|status|type)' "$file"
done

Length of output: 3515




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
Loading