188 lines
6.9 KiB
PL/PgSQL
188 lines
6.9 KiB
PL/PgSQL
BEGIN;
|
|
|
|
|
|
CREATE TABLE mock.sync_group_editing (
|
|
account_id INTEGER PRIMARY KEY REFERENCES mock.accounts ON DELETE CASCADE,
|
|
sync_group_id INTEGER NOT NULL REFERENCES mock.sync_groups ON DELETE CASCADE,
|
|
|
|
UNIQUE (account_id, sync_group_id),
|
|
UNIQUE (sync_group_id)
|
|
);
|
|
|
|
CREATE TABLE mock.sync_group_editing_listing_order_indexes (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL CHECK (order_index >= 0),
|
|
|
|
PRIMARY KEY (account_id, order_index)
|
|
);
|
|
|
|
CREATE TABLE mock.shop_amazon_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_amazon ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_big_cartel_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_big_cartel ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_ebay_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_ebay ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_ecwid_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_ecwid ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_etsy_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_etsy ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_shopify_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_shopify ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_square_online_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_square_online ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_squarespace_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_squarespace ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_tiktok_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_tiktok ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_walmart_marketplace_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_walmart_marketplace ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_wix_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_wix ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_woo_commerce_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_woo_commerce ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE mock.shop_zoho_sync_group_editing_listings (
|
|
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
|
|
order_index INTEGER NOT NULL,
|
|
shop_id TEXT NOT NULL,
|
|
listing_id TEXT,
|
|
|
|
PRIMARY KEY (account_id, order_index),
|
|
UNIQUE (account_id, shop_id),
|
|
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_zoho ON DELETE CASCADE,
|
|
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
|
|
);
|
|
|
|
|
|
|
|
GRANT ALL ON SCHEMA mock TO PUBLIC;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
COMMIT;
|