From de6ac08985252e7b5d36959896386a414e590d15 Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan@randomdan.homeip.net>
Date: Sat, 12 Jun 2021 19:21:22 +0100
Subject: Load schema and config etc from target DB

---
 lib/output/pq/sql/selectColumns.sql | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'lib/output/pq/sql/selectColumns.sql')

diff --git a/lib/output/pq/sql/selectColumns.sql b/lib/output/pq/sql/selectColumns.sql
index e9cd107..9c1cbab 100644
--- a/lib/output/pq/sql/selectColumns.sql
+++ b/lib/output/pq/sql/selectColumns.sql
@@ -1,6 +1,6 @@
-SELECT t.table_name, STRING_AGG(c.column_name, '|' ORDER BY c.ordinal_position)
+SELECT t.table_name, c.column_name, c.mysql_ordinal, k.column_name IS NOT NULL is_pk
 FROM mygrate.source s
-	JOIN information_schema.tables t USING(table_schema)
-	LEFT OUTER JOIN information_schema.columns c USING(table_schema, table_name)
-WHERE s.id = $1
-GROUP BY t.table_name
+	JOIN mygrate.tables t USING(source_id)
+	JOIN mygrate.table_columns c USING(table_id)
+	LEFT OUTER JOIN information_schema.key_column_usage k USING(table_schema, table_name, column_name)
+WHERE s.source_id = $1
-- 
cgit v1.2.3

