Skip to content

Instantly share code, notes, and snippets.

@danielfone
Created August 26, 2018 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielfone/16b70cee3b31b69397a3c350d707ff7f to your computer and use it in GitHub Desktop.
Save danielfone/16b70cee3b31b69397a3c350d707ff7f to your computer and use it in GitHub Desktop.
-- Load projects from import
--
INSERT INTO projects (reference, name, created_at, updated_at)
SELECT
i.project_reference AS reference,
i.project_name AS name
now() AS created_at,
now() AS updated_at
FROM (SELECT DISTINCT project_reference, project_name FROM imported_reports) i
ON CONFLICT (reference) DO UPDATE SET
name = excluded.name,
updated_at = NOW()
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment