CREATE TYPE platform AS ENUM('Etsy', 'Tiktok', 'Wix'); CREATE TABLE sync_groups ( sync_group_id SERIAL PRIMARY KEY, account_id INTEGER NOT NULL REFERENCES accounts ); CREATE TABLE sync_group_listings ( sync_group_id INTEGER NOT NULL REFERENCES sync_groups, 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) ); CREATE TABLE sync_group_listing_drafts ( account_id INTEGER NOT NULL REFERENCES accounts, order_index INTEGER NOT NULL, platform platform, shop_id TEXT, listing_id TEXT, PRIMARY KEY (account_id, order_index) );