Skip to content

Commit

Permalink
✨ (migrations): Simplify shopifyDomain table structure, use domain as PK
Browse files Browse the repository at this point in the history
📝 (migrations): Update comments to reflect changes in shopifyDomain table
✨ (GraphQL): Add query for fetching Shopify domain by PK
✅ (tests): Add tests for new Shopify domain query and error handling
♻️ (Shopify handler): Refactor to include organizerId in request validation response
  • Loading branch information
sebpalluel committed Apr 19, 2024
1 parent 5adf4c0 commit c35638d
Show file tree
Hide file tree
Showing 10 changed files with 11,693 additions and 6,743 deletions.
24 changes: 4 additions & 20 deletions hasura/app/migrations/default/1713432670329_shopifyDomain/down.sql
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- -- Create the shopifyDomain table
-- CREATE TABLE "public"."shopifyDomain" (
-- id uuid DEFAULT gen_random_uuid() NOT NULL,
-- domain text NOT NULL,
-- CREATE TABLE "public"."shopifyDomain"(
-- domain text PRIMARY KEY,
-- "organizerId" text NOT NULL,
-- created_at timestamp with time zone DEFAULT now(),
-- updated_at timestamp with time zone DEFAULT now(),
-- PRIMARY KEY (id)
-- created_at timestamp with time zone DEFAULT now()
-- );
--
-- -- Create a unique index on the domain column for optimized querying
-- CREATE UNIQUE INDEX idx_shopify_domain_unique_domain ON "public"."shopifyDomain" (domain);
--
-- -- Comments on the purpose of the shopifyDomain table and its fields
-- COMMENT ON TABLE "public"."shopifyDomain" IS E'This table is used to link and authenticate queries from Shopify to an organizer in our system. It stores the unique Shopify domains associated with each organizer, allowing for efficient lookup and validation of incoming requests.';
--
-- COMMENT ON COLUMN "public"."shopifyDomain"."id" IS E'Unique identifier for each Shopify domain entry, generated automatically as a UUID.';
--
-- COMMENT ON COLUMN "public"."shopifyDomain"."domain" IS E'The Shopify domain value, which must be unique across the entire table to ensure accurate mapping between Shopify and our system.';
-- COMMENT ON COLUMN "public"."shopifyDomain"."domain" IS E'The Shopify domain value, which serves as the primary key for the table, ensuring uniqueness across all records.';
--
-- COMMENT ON COLUMN "public"."shopifyDomain"."organizerId" IS E'The unique identifier of the associated organizer in our external CRM system. This field is used to link Shopify domains to the corresponding organizers.';
--
-- COMMENT ON COLUMN "public"."shopifyDomain"."created_at" IS E'Timestamp indicating when the record was initially created, set automatically by the system.';
--
-- COMMENT ON COLUMN "public"."shopifyDomain"."updated_at" IS E'Timestamp indicating the last time the record was updated, automatically managed by a database trigger to ensure accuracy.';
--
-- -- Create trigger for updating the updated_at field in the shopifyDomain table
-- CREATE TRIGGER set_public_shopify_domain_updated_at
-- BEFORE UPDATE ON "public"."shopifyDomain"
-- FOR EACH ROW
-- EXECUTE FUNCTION public.set_current_timestamp_updated_at();
23 changes: 4 additions & 19 deletions hasura/app/migrations/default/1713432670329_shopifyDomain/up.sql
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
-- Create the shopifyDomain table
CREATE TABLE "public"."shopifyDomain" (
id uuid DEFAULT gen_random_uuid() NOT NULL,
domain text NOT NULL,
CREATE TABLE "public"."shopifyDomain"(
domain text PRIMARY KEY,
"organizerId" text NOT NULL,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now(),
PRIMARY KEY (id)
created_at timestamp with time zone DEFAULT now()
);

-- Create a unique index on the domain column for optimized querying
CREATE UNIQUE INDEX idx_shopify_domain_unique_domain ON "public"."shopifyDomain" (domain);

-- Comments on the purpose of the shopifyDomain table and its fields
COMMENT ON TABLE "public"."shopifyDomain" IS E'This table is used to link and authenticate queries from Shopify to an organizer in our system. It stores the unique Shopify domains associated with each organizer, allowing for efficient lookup and validation of incoming requests.';

COMMENT ON COLUMN "public"."shopifyDomain"."id" IS E'Unique identifier for each Shopify domain entry, generated automatically as a UUID.';

COMMENT ON COLUMN "public"."shopifyDomain"."domain" IS E'The Shopify domain value, which must be unique across the entire table to ensure accurate mapping between Shopify and our system.';
COMMENT ON COLUMN "public"."shopifyDomain"."domain" IS E'The Shopify domain value, which serves as the primary key for the table, ensuring uniqueness across all records.';

COMMENT ON COLUMN "public"."shopifyDomain"."organizerId" IS E'The unique identifier of the associated organizer in our external CRM system. This field is used to link Shopify domains to the corresponding organizers.';

COMMENT ON COLUMN "public"."shopifyDomain"."created_at" IS E'Timestamp indicating when the record was initially created, set automatically by the system.';

COMMENT ON COLUMN "public"."shopifyDomain"."updated_at" IS E'Timestamp indicating the last time the record was updated, automatically managed by a database trigger to ensure accuracy.';

-- Create trigger for updating the updated_at field in the shopifyDomain table
CREATE TRIGGER set_public_shopify_domain_updated_at
BEFORE UPDATE ON "public"."shopifyDomain"
FOR EACH ROW
EXECUTE FUNCTION public.set_current_timestamp_updated_at();
10 changes: 10 additions & 0 deletions libs/gql/admin/api/src/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,13 @@ ${EventParametersFieldsFragmentDoc}`;
heroImageClasses
}
}
}
`;
const GetShopifyDomainDocument = `
query GetShopifyDomain($domain: String!) @cached {
shopifyDomain_by_pk(domain: $domain) {
organizerId
}
}
`;
const GetEventPassNftByIdDocument = `
Expand Down Expand Up @@ -1785,6 +1792,9 @@ export function getSdk<C, E>(requester: Requester<C, E>) {
GetOrganizerLatestEvents(variables: Types.GetOrganizerLatestEventsQueryVariables, options?: C): Promise<Types.GetOrganizerLatestEventsQuery> {
return requester<Types.GetOrganizerLatestEventsQuery, Types.GetOrganizerLatestEventsQueryVariables>(GetOrganizerLatestEventsDocument, variables, options) as Promise<Types.GetOrganizerLatestEventsQuery>;
},
GetShopifyDomain(variables: Types.GetShopifyDomainQueryVariables, options?: C): Promise<Types.GetShopifyDomainQuery> {
return requester<Types.GetShopifyDomainQuery, Types.GetShopifyDomainQueryVariables>(GetShopifyDomainDocument, variables, options) as Promise<Types.GetShopifyDomainQuery>;
},
GetEventPassNftById(variables: Types.GetEventPassNftByIdQueryVariables, options?: C): Promise<Types.GetEventPassNftByIdQuery> {
return requester<Types.GetEventPassNftByIdQuery, Types.GetEventPassNftByIdQueryVariables>(GetEventPassNftByIdDocument, variables, options) as Promise<Types.GetEventPassNftByIdQuery>;
},
Expand Down
Loading

0 comments on commit c35638d

Please sign in to comment.