oops; put this into the migration_tools schema
[migration-tools.git] / sql / base / 00-infrastructure.sql
index 240a508..ea79446 100644 (file)
@@ -115,7 +115,7 @@ CREATE OR REPLACE FUNCTION migration_tools.create_linked_legacy_table_from (TEXT
     BEGIN
         create_sql := 'CREATE TABLE ' || migration_schema || '.' || parent_table || '_legacy ( ';
         FOR columns IN
-            SELECT table_schema, table_name, column_name, data_type
+            SELECT table_schema, table_name, column_name, data_type, numeric_precision, numeric_scale
             FROM information_schema.columns
             WHERE table_schema = migration_schema AND table_name = source_table
         LOOP
@@ -127,6 +127,8 @@ CREATE OR REPLACE FUNCTION migration_tools.create_linked_legacy_table_from (TEXT
             create_sql := create_sql || columns.column_name || ' ';
             if columns.data_type = 'ARRAY' then
                 create_sql := create_sql || 'TEXT[]';
+            elsif columns.data_type = 'numeric' then
+                create_sql := create_sql || 'NUMERIC('||columns.numeric_precision||','||columns.numeric_scale||')';
             else
                 create_sql := create_sql || columns.data_type;
             end if;
@@ -142,7 +144,7 @@ CREATE OR REPLACE FUNCTION migration_tools.create_linked_legacy_table_from (TEXT
 $$ LANGUAGE PLPGSQL STRICT VOLATILE;
 
 -- creates other child table so you can have more than one child table in a schema from a base table 
-CREATE OR REPLACE FUNCTION build_variant_staging_table(text, text, text)
+CREATE OR REPLACE FUNCTION migration_tools.build_variant_staging_table(text, text, text)
  RETURNS void
  LANGUAGE plpgsql
  STRICT