Skip to content

Commit

Permalink
Revert "Ensure added columns are ordered (#240)" (#245)
Browse files Browse the repository at this point in the history
This reverts commit 9f8c5b7.
  • Loading branch information
rymurr authored Sep 6, 2023
1 parent 621a9c0 commit 8a2c01f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions bootstrap/005_table_migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ BEGIN
END IF;

let columns_to_add string := (
SELECT LISTAGG('"' || COLUMN_NAME || '" ' || DATA_TYPE, ', ') WITHIN GROUP (ORDER BY ORDINAL_POSITION) as cols

SELECT LISTAGG('"' || COLUMN_NAME || '" ' || DATA_TYPE, ', ')
FROM (
SELECT COLUMN_NAME, DATA_TYPE, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :view_schema AND TABLE_NAME = :view_name
SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :view_schema AND TABLE_NAME = :view_name
MINUS
SELECT COLUMN_NAME, DATA_TYPE, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :table_schema AND TABLE_NAME = :table_name
SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :table_schema AND TABLE_NAME = :table_name
)

);

let columns_to_drop string := (
SELECT LISTAGG('"' || COLUMN_NAME || '" ' , ', ') WITHIN GROUP (ORDER BY ORDINAL_POSITION) as cols

SELECT LISTAGG('"' || COLUMN_NAME || '" ' , ', ')
FROM (
SELECT COLUMN_NAME, DATA_TYPE, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :table_schema AND TABLE_NAME = :table_name
SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :table_schema AND TABLE_NAME = :table_name
MINUS
SELECT COLUMN_NAME, DATA_TYPE, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :view_schema AND TABLE_NAME = :view_name
SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = :view_schema AND TABLE_NAME = :view_name
)

);
Expand Down

0 comments on commit 8a2c01f

Please sign in to comment.