-- Storefront deploy wiring (Super Admin Add Domain + git URL)
ALTER TABLE domains
  ADD COLUMN IF NOT EXISTS deploy_slug VARCHAR(64),
  ADD COLUMN IF NOT EXISTS git_repo_url VARCHAR(512);

CREATE UNIQUE INDEX IF NOT EXISTS domains_deploy_slug_unique
  ON domains (deploy_slug)
  WHERE deploy_slug IS NOT NULL;

-- Existing websites VM sites
UPDATE domains
SET deploy_slug = 'ali-mohammadi',
    git_repo_url = COALESCE(git_repo_url, 'git@git.meshkee.com:Meshkee-Websites/ali-mohammadi.git')
WHERE host = 'ali-mohammadi.ir'
  AND deploy_slug IS NULL;

UPDATE domains
SET deploy_slug = 'meshkee',
    git_repo_url = COALESCE(git_repo_url, 'git@git.meshkee.com:Meshkee-Websites/meshkee.git')
WHERE host = 'meshkee.com'
  AND deploy_slug IS NULL;
