From b182685ec3f6f462ade9798e7bf79d5c60aa0d96 Mon Sep 17 00:00:00 2001 From: Angel Beltran Date: Wed, 21 Jan 2026 20:15:44 -0700 Subject: [PATCH] mock store tables stubbed in db schema --- .../000013_sync_group_table_state.up.sql | 6 +- .../000015_mock_accounts.down.sql | 31 ++ .../000015_mock_accounts.up.sql | 143 ++++++++ diagrams/database_schema.svg | 2 +- diagrams/database_schema.uml | 307 +++++++++++++++++- 5 files changed, 476 insertions(+), 13 deletions(-) create mode 100644 database_migrations/000015_mock_accounts.down.sql create mode 100644 database_migrations/000015_mock_accounts.up.sql diff --git a/database_migrations/000013_sync_group_table_state.up.sql b/database_migrations/000013_sync_group_table_state.up.sql index 26529ac..542329b 100644 --- a/database_migrations/000013_sync_group_table_state.up.sql +++ b/database_migrations/000013_sync_group_table_state.up.sql @@ -8,9 +8,9 @@ CREATE TABLE sync_groups ( CREATE TABLE sync_group_listings ( sync_group_id INTEGER NOT NULL REFERENCES sync_groups, order_index INTEGER NOT NULL, - platform platform, - shop_id TEXT, - listing_id TEXT, + platform platform NOT NULL, + shop_id TEXT NOT NULL, + listing_id TEXT NOT NULL, PRIMARY KEY (sync_group_id, order_index) ); diff --git a/database_migrations/000015_mock_accounts.down.sql b/database_migrations/000015_mock_accounts.down.sql new file mode 100644 index 0000000..c7debda --- /dev/null +++ b/database_migrations/000015_mock_accounts.down.sql @@ -0,0 +1,31 @@ +BEGIN; + + +-- mock sync group listings + +DROP TABLE mock_sync_group_listings; +DROP TABLE mock_sync_groups; + + +-- mock stores + +DROP TABLE mock_store_ebay; +DROP TABLE mock_store_walmart_marketplace; +DROP TABLE mock_store_amazon; +DROP TABLE mock_store_big_cartel; +DROP TABLE mock_store_ecwid; +DROP TABLE mock_store_zoho; +DROP TABLE mock_store_square_online; +DROP TABLE mock_store_squarespace; +DROP TABLE mock_store_wix; +DROP TABLE mock_store_woo_commerce; +DROP TABLE mock_store_shopify; +DROP TABLE mock_store_tiktok; + + +-- mock accounts + +DROP TABLE mock_accounts; + + +COMMIT; diff --git a/database_migrations/000015_mock_accounts.up.sql b/database_migrations/000015_mock_accounts.up.sql new file mode 100644 index 0000000..3294473 --- /dev/null +++ b/database_migrations/000015_mock_accounts.up.sql @@ -0,0 +1,143 @@ +BEGIN; + + +-- mock accounts + +CREATE TABLE mock_accounts ( + account_id SERIAL PRIMARY KEY, + user_id TEXT NOT NULL REFERENCES oauth_users (user_id) +); +CREATE UNIQUE INDEX ON mock_accounts (user_id); +CREATE UNIQUE INDEX ON mock_accounts (account_id, user_id); + + +-- mock stores + +CREATE TABLE mock_store_tiktok ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_shopify ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_woo_commerce ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_wix ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_squarespace ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_square_online ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_zoho ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_ecwid ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_big_cartel ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_amazon ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_walmart_marketplace ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + +CREATE TABLE mock_store_ebay ( + user_id TEXT NOT NULL REFERENCES oauth_users (user_id), + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id), + store_id TEXT PRIMARY KEY, + name TEXT NOT NULL CHECK (char_length(name) > 0), + + FOREIGN KEY (account_id, user_id) REFERENCES mock_accounts (account_id, user_id) +); + + +-- mock sync group listings + +CREATE TABLE mock_sync_groups ( + sync_group_id SERIAL PRIMARY KEY, + account_id INTEGER NOT NULL REFERENCES mock_accounts (account_id) +); + +CREATE TABLE mock_sync_group_listings ( + sync_group_id INTEGER NOT NULL REFERENCES mock_sync_groups (sync_group_id), + order_index INTEGER NOT NULL, + platform platform NOT NULL, + shop_id TEXT NOT NULL, + listing_id TEXT NOT NULL, + + PRIMARY KEY (sync_group_id, order_index) +); + + +COMMIT; diff --git a/diagrams/database_schema.svg b/diagrams/database_schema.svg index 02c66f8..c9230ff 100644 --- a/diagrams/database_schema.svg +++ b/diagrams/database_schema.svg @@ -1 +1 @@ -accountsaccount_id:serial [PK]email:textverified:booleanuser_id:text [FK]etsy_access_tokensuser_id:integer [PK][FK]access_token:textrefresh_token:textaccess_token_expiration:timestamp with time zonerefresh_token_expiration:timestamp with time zoneetsy_oauth_requestsstate:bytea [PK]code_verifier:byteaexpiration:timestamp with time zoneaccount_id:integer [FK]etsy_store_eventsstore_id:text [PK][FK]event_timestamp:timestamp with time zone [PK][FK]event_id:text [PK][FK]platform:text [FK]etsy_usersuser_id:integer [PK]account_id:integer [FK]shop_id:integeroauth_login_statesstate:bytea [PK]expiration:timestamp with time zonetarget_uri:textoauth_tokensaccess_token:text [PK]token_type:textrefresh_token:textexpiry:timestamp with time zoneid_token_issuer:textid_token_audience:text[]id_token_subject:text [FK]id_token_expiry:timestamp with time zoneid_token_issued_at:timestamp with time zoneid_token_nonce:textid_token_access_token_hash:textclaims:jsonboauth_usersuser_id:text [PK]raw_store_eventsplatform:text [PK]store_id:text [PK]event_timestamp:timestamp with time zone [PK]event_id:text [PK]raw_payload:jsonbschema_migrationsversion:bigint [PK]dirty:booleansync_group_listing_draftsaccount_id:integer [PK][FK]order_index:integer [PK]platform:platformshop_id:textlisting_id:textsync_group_listingssync_group_id:integer [PK][FK]order_index:integer [PK]platform:platformshop_id:textlisting_id:textsync_groupssync_group_id:serial [PK]account_id:integer [FK]tiktok_store_eventsstore_id:text [PK][FK]event_timestamp:timestamp with time zone [PK][FK]event_id:text [PK][FK]platform:text [FK]wix_store_eventsstore_id:text [PK][FK]event_timestamp:timestamp with time zone [PK][FK]event_id:text [PK][FK]platform:text [FK] \ No newline at end of file +accountsaccount_id:serial [PK]email:textverified:booleanuser_id:text [FK]etsy_access_tokensuser_id:integer [PK][FK]access_token:textrefresh_token:textaccess_token_expiration:timestamp with time zonerefresh_token_expiration:timestamp with time zoneetsy_oauth_requestsstate:bytea [PK]code_verifier:byteaexpiration:timestamp with time zoneaccount_id:integer [FK]etsy_store_eventsstore_id:text [PK][FK]event_timestamp:timestamp with time zone [PK][FK]event_id:text [PK][FK]platform:text [FK]etsy_usersuser_id:integer [PK]account_id:integer [FK]shop_id:integermock_accountsaccount_id:serial [PK]user_id:text [FK]mock_store_amazonstore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_big_cartelstore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_ebaystore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_ecwidstore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_shopifystore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_square_onlinestore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_squarespacestore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_tiktokstore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_walmart_marketplacestore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_wixstore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_woo_commercestore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_store_zohostore_id:text [PK]user_id:text [FK]account_id:integer [FK]name:textmock_sync_group_listingssync_group_id:integer [PK][FK]order_index:integer [PK]platform:platformshop_id:textlisting_id:textmock_sync_groupssync_group_id:serial [PK]account_id:integer [FK]oauth_login_statesstate:bytea [PK]expiration:timestamp with time zonetarget_uri:textoauth_tokensaccess_token:text [PK]token_type:textrefresh_token:textexpiry:timestamp with time zoneid_token_issuer:textid_token_audience:text[]id_token_subject:text [FK]id_token_expiry:timestamp with time zoneid_token_issued_at:timestamp with time zoneid_token_nonce:textid_token_access_token_hash:textclaims:jsonboauth_usersuser_id:text [PK]raw_store_eventsplatform:text [PK]store_id:text [PK]event_timestamp:timestamp with time zone [PK]event_id:text [PK]raw_payload:jsonbschema_migrationsversion:bigint [PK]dirty:booleansync_group_listing_draftsaccount_id:integer [PK][FK]order_index:integer [PK]platform:platformshop_id:textlisting_id:textsync_group_listingssync_group_id:integer [PK][FK]order_index:integer [PK]platform:platformshop_id:textlisting_id:textsync_groupssync_group_id:serial [PK]account_id:integer [FK]tiktok_store_eventsstore_id:text [PK][FK]event_timestamp:timestamp with time zone [PK][FK]event_id:text [PK][FK]platform:text [FK]wix_store_eventsstore_id:text [PK][FK]event_timestamp:timestamp with time zone [PK][FK]event_id:text [PK][FK]platform:text [FK] \ No newline at end of file diff --git a/diagrams/database_schema.uml b/diagrams/database_schema.uml index df7fe93..e85907b 100644 --- a/diagrams/database_schema.uml +++ b/diagrams/database_schema.uml @@ -42,6 +42,123 @@ entity "**etsy_users**" { *""shop_id"": //integer // } +entity "**mock_accounts**" { + + ""account_id"": //serial [PK]// + -- + *""user_id"": //text [FK]// +} + +entity "**mock_store_amazon**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_big_cartel**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_ebay**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_ecwid**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_shopify**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_square_online**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_squarespace**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_tiktok**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_walmart_marketplace**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_wix**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_woo_commerce**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_store_zoho**" { + + ""store_id"": //text [PK]// + -- + *""user_id"": //text [FK]// + *""account_id"": //integer [FK]// + *""name"": //text // +} + +entity "**mock_sync_group_listings**" { + + ""sync_group_id"": //integer [PK][FK]// + + ""order_index"": //integer [PK]// + -- + *""platform"": //platform // + *""shop_id"": //text // + *""listing_id"": //text // +} + +entity "**mock_sync_groups**" { + + ""sync_group_id"": //serial [PK]// + -- + *""account_id"": //integer [FK]// +} + entity "**oauth_login_states**" { + ""state"": //bytea [PK]// -- @@ -98,9 +215,9 @@ entity "**sync_group_listings**" { + ""sync_group_id"": //integer [PK][FK]// + ""order_index"": //integer [PK]// -- - ""platform"": //platform // - ""shop_id"": //text // - ""listing_id"": //text // + *""platform"": //platform // + *""shop_id"": //text // + *""listing_id"": //text // } entity "**sync_groups**" { @@ -141,6 +258,184 @@ entity "**wix_store_events**" { "**etsy_users**" }-- "**accounts**" +"**mock_accounts**" }-- "**oauth_users**" + +"**mock_accounts**" }-- "**oauth_users**" + +"**mock_store_amazon**" }-- "**mock_accounts**" + +"**mock_store_amazon**" }-- "**mock_accounts**" + +"**mock_store_amazon**" }-- "**mock_accounts**" + +"**mock_store_amazon**" }-- "**mock_accounts**" + +"**mock_store_amazon**" }-- "**mock_accounts**" + +"**mock_store_amazon**" }-- "**mock_accounts**" + +"**mock_store_amazon**" }-- "**oauth_users**" + +"**mock_store_big_cartel**" }-- "**mock_accounts**" + +"**mock_store_big_cartel**" }-- "**mock_accounts**" + +"**mock_store_big_cartel**" }-- "**mock_accounts**" + +"**mock_store_big_cartel**" }-- "**mock_accounts**" + +"**mock_store_big_cartel**" }-- "**mock_accounts**" + +"**mock_store_big_cartel**" }-- "**mock_accounts**" + +"**mock_store_big_cartel**" }-- "**oauth_users**" + +"**mock_store_ebay**" }-- "**mock_accounts**" + +"**mock_store_ebay**" }-- "**mock_accounts**" + +"**mock_store_ebay**" }-- "**mock_accounts**" + +"**mock_store_ebay**" }-- "**mock_accounts**" + +"**mock_store_ebay**" }-- "**mock_accounts**" + +"**mock_store_ebay**" }-- "**mock_accounts**" + +"**mock_store_ebay**" }-- "**oauth_users**" + +"**mock_store_ecwid**" }-- "**mock_accounts**" + +"**mock_store_ecwid**" }-- "**mock_accounts**" + +"**mock_store_ecwid**" }-- "**mock_accounts**" + +"**mock_store_ecwid**" }-- "**mock_accounts**" + +"**mock_store_ecwid**" }-- "**mock_accounts**" + +"**mock_store_ecwid**" }-- "**mock_accounts**" + +"**mock_store_ecwid**" }-- "**oauth_users**" + +"**mock_store_shopify**" }-- "**mock_accounts**" + +"**mock_store_shopify**" }-- "**mock_accounts**" + +"**mock_store_shopify**" }-- "**mock_accounts**" + +"**mock_store_shopify**" }-- "**mock_accounts**" + +"**mock_store_shopify**" }-- "**mock_accounts**" + +"**mock_store_shopify**" }-- "**mock_accounts**" + +"**mock_store_shopify**" }-- "**oauth_users**" + +"**mock_store_square_online**" }-- "**mock_accounts**" + +"**mock_store_square_online**" }-- "**mock_accounts**" + +"**mock_store_square_online**" }-- "**mock_accounts**" + +"**mock_store_square_online**" }-- "**mock_accounts**" + +"**mock_store_square_online**" }-- "**mock_accounts**" + +"**mock_store_square_online**" }-- "**mock_accounts**" + +"**mock_store_square_online**" }-- "**oauth_users**" + +"**mock_store_squarespace**" }-- "**mock_accounts**" + +"**mock_store_squarespace**" }-- "**mock_accounts**" + +"**mock_store_squarespace**" }-- "**mock_accounts**" + +"**mock_store_squarespace**" }-- "**mock_accounts**" + +"**mock_store_squarespace**" }-- "**mock_accounts**" + +"**mock_store_squarespace**" }-- "**mock_accounts**" + +"**mock_store_squarespace**" }-- "**oauth_users**" + +"**mock_store_tiktok**" }-- "**mock_accounts**" + +"**mock_store_tiktok**" }-- "**mock_accounts**" + +"**mock_store_tiktok**" }-- "**mock_accounts**" + +"**mock_store_tiktok**" }-- "**mock_accounts**" + +"**mock_store_tiktok**" }-- "**mock_accounts**" + +"**mock_store_tiktok**" }-- "**mock_accounts**" + +"**mock_store_tiktok**" }-- "**oauth_users**" + +"**mock_store_walmart_marketplace**" }-- "**mock_accounts**" + +"**mock_store_walmart_marketplace**" }-- "**mock_accounts**" + +"**mock_store_walmart_marketplace**" }-- "**mock_accounts**" + +"**mock_store_walmart_marketplace**" }-- "**mock_accounts**" + +"**mock_store_walmart_marketplace**" }-- "**mock_accounts**" + +"**mock_store_walmart_marketplace**" }-- "**mock_accounts**" + +"**mock_store_walmart_marketplace**" }-- "**oauth_users**" + +"**mock_store_wix**" }-- "**mock_accounts**" + +"**mock_store_wix**" }-- "**mock_accounts**" + +"**mock_store_wix**" }-- "**mock_accounts**" + +"**mock_store_wix**" }-- "**mock_accounts**" + +"**mock_store_wix**" }-- "**mock_accounts**" + +"**mock_store_wix**" }-- "**mock_accounts**" + +"**mock_store_wix**" }-- "**oauth_users**" + +"**mock_store_woo_commerce**" }-- "**mock_accounts**" + +"**mock_store_woo_commerce**" }-- "**mock_accounts**" + +"**mock_store_woo_commerce**" }-- "**mock_accounts**" + +"**mock_store_woo_commerce**" }-- "**mock_accounts**" + +"**mock_store_woo_commerce**" }-- "**mock_accounts**" + +"**mock_store_woo_commerce**" }-- "**mock_accounts**" + +"**mock_store_woo_commerce**" }-- "**oauth_users**" + +"**mock_store_zoho**" }-- "**mock_accounts**" + +"**mock_store_zoho**" }-- "**mock_accounts**" + +"**mock_store_zoho**" }-- "**mock_accounts**" + +"**mock_store_zoho**" }-- "**mock_accounts**" + +"**mock_store_zoho**" }-- "**mock_accounts**" + +"**mock_store_zoho**" }-- "**mock_accounts**" + +"**mock_store_zoho**" }-- "**oauth_users**" + +"**mock_sync_group_listings**" }-- "**mock_sync_groups**" + +"**mock_sync_groups**" }-- "**mock_accounts**" + +"**mock_sync_groups**" }-- "**mock_accounts**" + "**oauth_tokens**" }-- "**oauth_users**" "**sync_group_listing_drafts**" }-- "**accounts**" @@ -151,12 +446,6 @@ entity "**wix_store_events**" { "**sync_group_listings**" }-- "**sync_groups**" -"**sync_group_listings**" }-- "**sync_groups**" - -"**sync_group_listings**" }-- "**sync_groups**" - -"**sync_group_listings**" }-- "**sync_groups**" - "**sync_groups**" }-- "**accounts**" "**tiktok_store_events**" }-- "**raw_store_events**"