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 @@
-
\ No newline at end of file
+
\ 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**"