Skip to content

resetting sequences fails #1691

@acnicholls

Description

@acnicholls

I built a discord bot and used EFCore for the data layer, so I could abstract the database provider. I use the Migrations to create the database schema, and initial seed values in a table or two. I have recently started the switch from SQL Server to PostgreSQL. After I run a data load, I cannot insert new rows due to the sequence value not taking on the highest IDENTITY value in the table.

in the meantime, i have identified a fix of manually resetting the sequences in the AFTER LOAD DO section.
EDIT: the script I wanted to use in the AFTER LOAD DO section was refused in many configurations, I am unsure if I should enter a second ticket for it. I will post the updated section content if you ask for it. perhaps it was just too complex for that section to handle.

here's the pg.loader file

load database
     from mssql://sccn-job-bot:sccn-job-bot@localhost/sccn-job-bot-dev
     into postgresql://sccn-job-bot:sccn-job-bot@localhost/sccn-bot
     WITH quote identifiers, data only, reset sequences
     alter schema 'dbo' rename to 'public'

     WITH workers = 8, concurrency = 1

     CAST 
          column Contracts.ConstructionExpiry to timestamptz,
          column Contracts.CreatedDate to date,
          column Contracts.SubmittedDate to date,
          column Contracts.ReviewedDate to date,
          column Contracts.StartedDate to date,
          column Contracts.CompletedDate to date,
          column Contracts.CancelledDate to date

     EXCLUDING TABLE NAMES like '__EFMigrationsHistory', 'Materials' in schema 'dbo'

set work_mem to '16MB', maintenance_work_mem to '512 MB'

AFTER LOAD DO
   $$  GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "sccn-job-bot"; $$
;

Here's the log

pgloader version 3.6.7~devel
compiled with SBCL 2.2.9.debian
sb-impl::*default-external-format* :UTF-8
tmpdir: #P"/tmp/pgloader/"
2025-11-05T02:33:58.012000Z NOTICE Starting pgloader, log system is ready.
2025-11-05T02:33:58.044000Z INFO Starting monitor
2025-11-05T02:33:58.060000Z LOG pgloader version "3.6.7~devel"
2025-11-05T02:33:58.199999Z INFO Parsed command:
load database
     from mssql://sccn-job-bot:sccn-job-bot@localhost/sccn-job-bot-dev
     into postgresql://sccn-job-bot:sccn-job-bot@localhost/sccn-bot
     WITH quote identifiers, data only, reset sequences
     alter schema 'dbo' rename to 'public'

     WITH workers = 8, concurrency = 1

     CAST
          column Contracts.ConstructionExpiry to timestamptz,
          column Contracts.CreatedDate to date,
          column Contracts.SubmittedDate to date,
          column Contracts.ReviewedDate to date,
          column Contracts.StartedDate to date,
          column Contracts.CompletedDate to date,
          column Contracts.CancelledDate to date

     EXCLUDING TABLE NAMES like '__EFMigrationsHistory', 'Materials' in schema 'dbo'

set work_mem to '16MB', maintenance_work_mem to '512 MB'

AFTER LOAD DO
   $$  GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "sccn-job-bot-stage"; $$
;

2025-11-05T02:33:58.215999Z DEBUG While compiling:

(LAMBDA ()
  (LET ((*MUFFLED-WARNINGS* 'STYLE-WARNING))
    (CFFI:LOAD-FOREIGN-LIBRARY 'MSSQL::SYBDB))
  (LET* ((PGLOADER.SOURCES:*DEFAULT-CAST-RULES*
          '((:SOURCE (:TYPE "char") :TARGET (:TYPE "text" :DROP-TYPEMOD T))
            (:SOURCE (:TYPE "nchar") :TARGET (:TYPE "text" :DROP-TYPEMOD T))
            (:SOURCE (:TYPE "varchar") :TARGET (:TYPE "text" :DROP-TYPEMOD T))
            (:SOURCE (:TYPE "nvarchar") :TARGET (:TYPE "text" :DROP-TYPEMOD T))
            (:SOURCE (:TYPE "ntext") :TARGET (:TYPE "text" :DROP-TYPEMOD T))
            (:SOURCE (:TYPE "xml") :TARGET (:TYPE "xml" :DROP-TYPEMOD T))
            (:SOURCE (:TYPE "int" :AUTO-INCREMENT T) :TARGET
             (:TYPE "bigserial" :DROP-DEFAULT T))
            (:SOURCE (:TYPE "bigint" :AUTO-INCREMENT T) :TARGET
             (:TYPE "bigserial"))
            (:SOURCE (:TYPE "smallint" :AUTO-INCREMENT T) :TARGET
             (:TYPE "smallserial"))
            (:SOURCE (:TYPE "tinyint") :TARGET (:TYPE "smallint"))
            (:SOURCE (:TYPE "tinyint" :AUTO-INCREMENT T) :TARGET
             (:TYPE "serial"))
            (:SOURCE (:TYPE "bit") :TARGET (:TYPE "boolean") :USING
             PGLOADER.TRANSFORMS::SQL-SERVER-BIT-TO-BOOLEAN)
            (:SOURCE (:TYPE "uniqueidentifier") :TARGET (:TYPE "uuid") :USING
             PGLOADER.TRANSFORMS::SQL-SERVER-UNIQUEIDENTIFIER-TO-UUID)
            (:SOURCE (:TYPE "hierarchyid") :TARGET (:TYPE "bytea") :USING
             PGLOADER.TRANSFORMS::BYTE-VECTOR-TO-BYTEA)
            (:SOURCE (:TYPE "geography") :TARGET (:TYPE "bytea") :USING
             PGLOADER.TRANSFORMS::BYTE-VECTOR-TO-BYTEA)
            (:SOURCE (:TYPE "float") :TARGET (:TYPE "float") :USING
             PGLOADER.TRANSFORMS::FLOAT-TO-STRING)
            (:SOURCE (:TYPE "real") :TARGET (:TYPE "real") :USING
             PGLOADER.TRANSFORMS::FLOAT-TO-STRING)
            (:SOURCE (:TYPE "double") :TARGET (:TYPE "double precision") :USING
             PGLOADER.TRANSFORMS::FLOAT-TO-STRING)
            (:SOURCE (:TYPE "numeric") :TARGET (:TYPE "numeric") :USING
             PGLOADER.TRANSFORMS::FLOAT-TO-STRING)
            (:SOURCE (:TYPE "decimal") :TARGET (:TYPE "numeric") :USING
             PGLOADER.TRANSFORMS::FLOAT-TO-STRING)
            (:SOURCE (:TYPE "money") :TARGET (:TYPE "numeric") :USING
             PGLOADER.TRANSFORMS::FLOAT-TO-STRING)
            (:SOURCE (:TYPE "smallmoney") :TARGET (:TYPE "numeric") :USING
             PGLOADER.TRANSFORMS::FLOAT-TO-STRING)
            (:SOURCE (:TYPE "binary") :TARGET (:TYPE "bytea") :USING
             PGLOADER.TRANSFORMS::BYTE-VECTOR-TO-BYTEA)
            (:SOURCE (:TYPE "image") :TARGET (:TYPE "bytea") :USING
             PGLOADER.TRANSFORMS::BYTE-VECTOR-TO-BYTEA)
            (:SOURCE (:TYPE "varbinary") :TARGET (:TYPE "bytea") :USING
             PGLOADER.TRANSFORMS::BYTE-VECTOR-TO-BYTEA)
            (:SOURCE (:TYPE "smalldatetime") :TARGET (:TYPE "timestamptz"))
            (:SOURCE (:TYPE "datetime") :TARGET (:TYPE "timestamptz"))
            (:SOURCE (:TYPE "datetime2") :TARGET (:TYPE "timestamptz"))
            (:SOURCE (:TYPE "datetimeoffset") :TARGET (:TYPE "timestamptz"))))
         (PGLOADER.SOURCES:*CAST-RULES*
          '((:SOURCE (:COLUMN ("Contracts" . "ConstructionExpiry")) :TARGET
             (:TYPE "timestamptz" :DROP-EXTRA NIL :DROP-DEFAULT NIL
              :DROP-TYPEMOD NIL :DROP-NOT-NULL NIL :SET-NOT-NULL NIL)
             :USING NIL)
            (:SOURCE (:COLUMN ("Contracts" . "CreatedDate")) :TARGET
             (:TYPE "date" :DROP-EXTRA NIL :DROP-DEFAULT NIL :DROP-TYPEMOD NIL
              :DROP-NOT-NULL NIL :SET-NOT-NULL NIL)
             :USING NIL)
            (:SOURCE (:COLUMN ("Contracts" . "SubmittedDate")) :TARGET
             (:TYPE "date" :DROP-EXTRA NIL :DROP-DEFAULT NIL :DROP-TYPEMOD NIL
              :DROP-NOT-NULL NIL :SET-NOT-NULL NIL)
             :USING NIL)
            (:SOURCE (:COLUMN ("Contracts" . "ReviewedDate")) :TARGET
             (:TYPE "date" :DROP-EXTRA NIL :DROP-DEFAULT NIL :DROP-TYPEMOD NIL
              :DROP-NOT-NULL NIL :SET-NOT-NULL NIL)
             :USING NIL)
            (:SOURCE (:COLUMN ("Contracts" . "StartedDate")) :TARGET
             (:TYPE "date" :DROP-EXTRA NIL :DROP-DEFAULT NIL :DROP-TYPEMOD NIL
              :DROP-NOT-NULL NIL :SET-NOT-NULL NIL)
             :USING NIL)
            (:SOURCE (:COLUMN ("Contracts" . "CompletedDate")) :TARGET
             (:TYPE "date" :DROP-EXTRA NIL :DROP-DEFAULT NIL :DROP-TYPEMOD NIL
              :DROP-NOT-NULL NIL :SET-NOT-NULL NIL)
             :USING NIL)
            (:SOURCE (:COLUMN ("Contracts" . "CancelledDate")) :TARGET
             (:TYPE "date" :DROP-EXTRA NIL :DROP-DEFAULT NIL :DROP-TYPEMOD NIL
              :DROP-NOT-NULL NIL :SET-NOT-NULL NIL)
             :USING NIL)))
         (PGLOADER.PARAMS:*MSSQL-SETTINGS* 'NIL)
         (PGLOADER.PARAMS:ON-ERROR-STOP
          (GETF '(:IDENTIFIER-CASE :QUOTE :DATA-ONLY T :RESET-SEQUENCES T)
                :ON-ERROR-STOP T))
         (PGLOADER.PARAMS:*PG-SETTINGS*
          (PGLOADER.PGSQL:SANITIZE-USER-GUCS
           '(("work_mem" . "16MB") ("maintenance_work_mem" . "512 MB"))))
         (PGLOADER.PARAMS:*PGSQL-RESERVED-KEYWORDS*
          (PGLOADER.PGSQL:LIST-RESERVED-KEYWORDS
           #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {10087F1B23}>))
         (PGLOADER.PARAMS:*COPY-BATCH-ROWS*
          (OR NIL PGLOADER.PARAMS:*COPY-BATCH-ROWS*))
         (PGLOADER.PARAMS:*COPY-BATCH-SIZE*
          (OR NIL PGLOADER.PARAMS:*COPY-BATCH-SIZE*))
         (PGLOADER.PARAMS:*PREFETCH-ROWS*
          (OR NIL PGLOADER.PARAMS:*PREFETCH-ROWS*))
         (PGLOADER.PARAMS:*ROWS-PER-RANGE*
          (OR NIL PGLOADER.PARAMS:*ROWS-PER-RANGE*))
         (PGLOADER.PARAMS:*IDENTIFIER-CASE*
          (OR :QUOTE PGLOADER.PARAMS:*IDENTIFIER-CASE*))
         (PGLOADER.PARSER::SOURCE
          (MAKE-INSTANCE 'PGLOADER.SOURCE.MSSQL:COPY-MSSQL :TARGET-DB
                         #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {10087F1B23}>
                         :SOURCE-DB
                         #<PGLOADER.SOURCE.MSSQL:MSSQL-CONNECTION mssql://sccn-job-bot-stage@localhost:1433/sccn-bot-stage {10087F1143}>)))
    NIL
    (PGLOADER.LOAD:COPY-DATABASE PGLOADER.PARSER::SOURCE :INCLUDING 'NIL
                                 :EXCLUDING
                                 '(("dbo" "__EFMigrationsHistory" "Materials"))
                                 :ALTER-SCHEMA
                                 '((#S(PGLOADER.CATALOG:MATCH-RULE
                                       :RULE #S(PGLOADER.CATALOG:STRING-MATCH-RULE
                                                :TARGET "dbo")
                                       :SCHEMA NIL
                                       :ACTION #<FUNCTION PGLOADER.CATALOG::ALTER-SCHEMA-RENAME>
                                       :ARGS ("public"))))
                                 :ALTER-TABLE 'NIL :AFTER-SCHEMA 'NIL
                                 :MATERIALIZE-VIEWS 'NIL :DISTRIBUTE 'NIL
                                 :SET-TABLE-OIDS T :ON-ERROR-STOP
                                 PGLOADER.PARAMS:ON-ERROR-STOP :DATA-ONLY T
                                 :RESET-SEQUENCES T)
    (PGLOADER.PARSER:EXECUTE-SQL-CODE-BLOCK
     #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {10087F1B23}>
     :POST
     '("GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO \"sccn-job-bot-stage\";")
     "after load")))
; in: LAMBDA ()
;     (OR :QUOTE PGLOADER.PARAMS:*IDENTIFIER-CASE*)
; --> IF
; ==>
;   PGLOADER.PARAMS:*IDENTIFIER-CASE*
;
; note: deleting unreachable code
;
; compilation unit finished
;   printed 1 note
2025-11-05T02:33:58.635995Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {10087F1B23}>
2025-11-05T02:33:58.635995Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:33:58.635995Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:33:58.639995Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:33:58.639995Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:33:58.687995Z LOG Migrating from #<MSSQL-CONNECTION mssql://sccn-job-bot-stage@localhost:1433/sccn-bot-stage {10087F1143}>
2025-11-05T02:33:58.687995Z LOG Migrating into #<PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {10087F1B23}>
Max connections reached, increase value of TDS_MAX_CONN
2025-11-05T02:33:58.791995Z SQL MSSQL: sending query: -- params: dbname
--         table-type-name
--         including
--         filter-list-to-where-clause including
--         excluding
--         filter-list-to-where-clause excluding
  select c.TABLE_SCHEMA,
         c.TABLE_NAME,
         c.COLUMN_NAME,
         c.DATA_TYPE,
         CASE
         WHEN c.COLUMN_DEFAULT LIKE '((%' AND c.COLUMN_DEFAULT LIKE '%))' THEN
             CASE
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) = 'newid()' THEN 'GENERATE_UUID'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) LIKE 'convert(%varchar%,getdate(),%)' THEN 'today'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) = 'getdate()' THEN 'CURRENT_TIMESTAMP'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) = 'sysdatetimeoffset()' THEN 'CURRENT_TIMESTAMP'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) LIKE '''%''' THEN SUBSTRING(c.COLUMN_DEFAULT,4,len(c.COLUMN_DEFAULT)-6)
                 ELSE SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4)
             END
         WHEN c.COLUMN_DEFAULT LIKE '(%' AND c.COLUMN_DEFAULT LIKE '%)' THEN
             CASE
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) = 'newid()' THEN 'GENERATE_UUID'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) LIKE 'convert(%varchar%,getdate(),%)' THEN 'today'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) = 'getdate()' THEN 'CURRENT_TIMESTAMP'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) = 'sysdatetimeoffset()' THEN 'CURRENT_TIMESTAMP'
                 WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) LIKE '''%''' THEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4)
                 ELSE SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2)
             END
         ELSE c.COLUMN_DEFAULT
         END,
         c.IS_NULLABLE,
         COLUMNPROPERTY(object_id(c.TABLE_NAME), c.COLUMN_NAME, 'IsIdentity'),
         c.CHARACTER_MAXIMUM_LENGTH,
         c.NUMERIC_PRECISION,
         c.NUMERIC_PRECISION_RADIX,
         c.NUMERIC_SCALE,
         c.DATETIME_PRECISION,
         c.CHARACTER_SET_NAME,
         c.COLLATION_NAME

    from INFORMATION_SCHEMA.COLUMNS c
         join INFORMATION_SCHEMA.TABLES t
              on c.TABLE_SCHEMA = t.TABLE_SCHEMA
             and c.TABLE_NAME = t.TABLE_NAME

   where     c.TABLE_CATALOG = 'sccn-bot-stage'
         and t.TABLE_TYPE = 'BASE TABLE'

         and ((c.table_schema = 'dbo' and c.table_name NOT LIKE '__EFMigrationsHistory')
           and (c.table_schema = 'dbo' and c.table_name NOT LIKE 'Materials'))

order by c.table_schema, c.table_name, c.ordinal_position;
2025-11-05T02:33:59.043994Z SQL MSSQL: sending query: -- params: dbname
--         including
--         filter-list-to-where-clause including
--         excluding
--         filter-list-to-where-clause excluding
   SELECT
           REPLACE(KCU1.CONSTRAINT_NAME, '.', '_') AS 'CONSTRAINT_NAME'
         , KCU1.TABLE_SCHEMA AS 'TABLE_SCHEMA'
         , KCU1.TABLE_NAME AS 'TABLE_NAME'
         , KCU1.COLUMN_NAME AS 'COLUMN_NAME'
         , KCU2.TABLE_SCHEMA AS 'UNIQUE_TABLE_SCHEMA'
         , KCU2.TABLE_NAME AS 'UNIQUE_TABLE_NAME'
         , KCU2.COLUMN_NAME AS 'UNIQUE_COLUMN_NAME'
         , RC.UPDATE_RULE AS 'UPDATE_RULE'
         , RC.DELETE_RULE AS 'DELETE_RULE'

    FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC
         JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU1
              ON KCU1.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG
                 AND KCU1.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA
                 AND KCU1.CONSTRAINT_NAME = RC.CONSTRAINT_NAME
         JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU2
              ON KCU2.CONSTRAINT_CATALOG = RC.UNIQUE_CONSTRAINT_CATALOG
                 AND KCU2.CONSTRAINT_SCHEMA = RC.UNIQUE_CONSTRAINT_SCHEMA
                 AND KCU2.CONSTRAINT_NAME = RC.UNIQUE_CONSTRAINT_NAME

   WHERE KCU1.ORDINAL_POSITION = KCU2.ORDINAL_POSITION
         AND KCU1.TABLE_CATALOG = 'sccn-bot-stage'
         AND KCU1.CONSTRAINT_CATALOG = 'sccn-bot-stage'
         AND KCU1.CONSTRAINT_SCHEMA NOT IN ('dto', 'sys')
         AND KCU1.TABLE_SCHEMA NOT IN ('dto', 'sys')
         AND KCU2.TABLE_SCHEMA NOT IN ('dto', 'sys')


         and ((kcu1.table_schema = 'dbo' and kcu1.table_name NOT LIKE '__EFMigrationsHistory') and (kcu1.table_schema = 'dbo' and kcu1.table_name NOT LIKE 'Materials'))

ORDER BY KCU1.CONSTRAINT_NAME, KCU1.ORDINAL_POSITION;
2025-11-05T02:33:59.159993Z INFO Processing source catalogs
2025-11-05T02:33:59.247991Z NOTICE Prepare PostgreSQL database.
2025-11-05T02:33:59.443990Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {100A8C2393}>
2025-11-05T02:33:59.443990Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:33:59.443990Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:33:59.443990Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:33:59.443990Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:33:59.455990Z DEBUG BEGIN
2025-11-05T02:33:59.519989Z SQL --
-- get user defined SQL types
--
  select nt.nspname,
         extname,
         typname,
         case when enum.enumtypid is not null
              then array_agg(enum.enumlabel order by enumsortorder)
          end as enumvalues

    from pg_class c
         join pg_namespace n on n.oid = c.relnamespace
         left join pg_attribute a on c.oid = a.attrelid and a.attnum > 0
         join pg_type t on t.oid = a.atttypid
         left join pg_namespace nt on nt.oid = t.typnamespace
         left join pg_depend d on d.classid = 'pg_type'::regclass
                              and d.refclassid = 'pg_extension'::regclass
                              and d.objid = t.oid
         left join pg_extension e on refobjid = e.oid
         left join pg_enum enum on enum.enumtypid = t.oid

   where nt.nspname !~ '^pg_' and nt.nspname <> 'information_schema'
         and n.nspname !~ '^pg_' and n.nspname <> 'information_schema'
         and c.relkind in ('r', 'f', 'p')
           and ((n.nspname = 'public' and c.relname = 'BotUsers')
           or (n.nspname = 'public' and c.relname = 'Carriers')
           or (n.nspname = 'public' and c.relname = 'ContractCarrier')
           or (n.nspname = 'public' and c.relname = 'ContractMaterial')
           or (n.nspname = 'public' and c.relname = 'Contracts')
           or (n.nspname = 'public' and c.relname = 'SystemNames'))

         and
           (   t.typrelid = 0
            or
               (select c.relkind = 'c'
                 from pg_class c
                where c.oid = t.typrelid)
           )
           and not exists
             (
                select 1
                  from pg_type el
                 where el.oid = t.typelem
                   and el.typarray = t.oid
              )

group by nt.nspname, extname, typname, enumtypid
order by nt.nspname, extname, typname, enumtypid;
2025-11-05T02:33:59.535989Z SQL -- params: table-type-name
--         including
--         filter-list-to-where-clause for including
--         excluding
--         filter-list-to-where-clause for excluding
with seqattr as
 (
   select adrelid,
          adnum,
          pg_get_expr(d.adbin, d.adrelid) as adsrc,
          case when pg_get_expr(d.adbin, d.adrelid) ~ 'nextval'
               then substring(pg_get_expr(d.adbin, d.adrelid)
                              from '''([^'']+)'''
                    )
               else null
           end as seqname
     from pg_attrdef d
 )
    select nspname, relname, c.oid, attname,
           t.oid::regtype as type,
           case when atttypmod > 0
                then substring(format_type(t.oid, atttypmod) from '\d+(?:,\d+)?')
                else null
            end as typmod,
           attnotnull,
           case when atthasdef
                then pg_get_expr(def.adbin, def.adrelid)
            end as default           ,
           case when s.seqname is not null then 'auto_increment' end as extra
      from pg_class c
           join pg_namespace n on n.oid = c.relnamespace
           left join pg_attribute a on c.oid = a.attrelid
           join pg_type t on t.oid = a.atttypid and attnum > 0
           left join pg_attrdef def on a.attrelid = def.adrelid
                                   and a.attnum = def.adnum
                                   and a.atthasdef
           left join seqattr s on def.adrelid = s.adrelid
                              and def.adnum = s.adnum

     where nspname !~ '^pg_' and n.nspname <> 'information_schema'
           and relkind in ('r', 'f', 'p')
           and ((n.nspname = 'public' and c.relname = 'BotUsers')
           or (n.nspname = 'public' and c.relname = 'Carriers')
           or (n.nspname = 'public' and c.relname = 'ContractCarrier')
           or (n.nspname = 'public' and c.relname = 'ContractMaterial')
           or (n.nspname = 'public' and c.relname = 'Contracts')
           or (n.nspname = 'public' and c.relname = 'SystemNames'))


  order by nspname, relname, attnum;
2025-11-05T02:33:59.547989Z SQL -- params: including
--         filter-list-to-where-clause for including
--         excluding
--         filter-list-to-where-clause for excluding
  select n.nspname,
         i.relname,
         i.oid,
         rn.nspname,
         r.relname,
         indisprimary,
         indisunique,
         (select string_agg(attname, ',')
            from pg_attribute
           where attrelid = r.oid
             and array[attnum::integer] <@ indkey::integer[]
         ) as cols,
         pg_get_indexdef(indexrelid),
         c.conname,
         pg_get_constraintdef(c.oid)
    from pg_index x
         join pg_class i ON i.oid = x.indexrelid
         join pg_class r ON r.oid = x.indrelid
         join pg_namespace n ON n.oid = i.relnamespace
         join pg_namespace rn ON rn.oid = r.relnamespace
         left join pg_depend d on d.classid = 'pg_class'::regclass
                              and d.objid = i.oid
                              and d.refclassid = 'pg_constraint'::regclass
                              and d.deptype = 'i'
         left join pg_constraint c ON c.oid = d.refobjid
   where n.nspname !~ '^pg_' and n.nspname <> 'information_schema'
         and ((rn.nspname = 'public' and r.relname = 'BotUsers')
           or (rn.nspname = 'public' and r.relname = 'Carriers')
           or (rn.nspname = 'public' and r.relname = 'ContractCarrier')
           or (rn.nspname = 'public' and r.relname = 'ContractMaterial')
           or (rn.nspname = 'public' and r.relname = 'Contracts')
           or (rn.nspname = 'public' and r.relname = 'SystemNames'))

order by n.nspname, r.relname
2025-11-05T02:33:59.587989Z SQL -- params: including (table)
--         filter-list-to-where-clause for including
--         excluding (table)
--         filter-list-to-where-clause for excluding
--         including (ftable)
--         filter-list-to-where-clause for including
--         excluding (ftable)
--         filter-list-to-where-clause for excluding
 select n.nspname, c.relname, nf.nspname, cf.relname as frelname,
        r.oid,
        d.refobjid as pkeyoid,
        conname,
        pg_catalog.pg_get_constraintdef(r.oid, true) as condef,
        (select string_agg(attname, ',')
           from pg_attribute
          where attrelid = r.conrelid
            and array[attnum::integer] <@ conkey::integer[]
        ) as conkey,
        (select string_agg(attname, ',')
           from pg_attribute
          where attrelid = r.confrelid
            and array[attnum::integer] <@ confkey::integer[]
        ) as confkey,
        confupdtype, confdeltype, confmatchtype,
        condeferrable, condeferred
   from pg_catalog.pg_constraint r
        JOIN pg_class c on r.conrelid = c.oid
        JOIN pg_namespace n on c.relnamespace = n.oid
        JOIN pg_class cf on r.confrelid = cf.oid
        JOIN pg_namespace nf on cf.relnamespace = nf.oid
        JOIN pg_depend d on d.classid = 'pg_constraint'::regclass
                        and d.objid = r.oid
                        and d.refobjsubid = 0
   where r.contype = 'f'
         AND c.relkind in ('r', 'f', 'p')
         AND cf.relkind in ('r', 'f', 'p')
         AND n.nspname !~ '^pg_' and n.nspname <> 'information_schema'
         AND nf.nspname !~ '^pg_' and nf.nspname <> 'information_schema'
         and ((n.nspname = 'public' and c.relname = 'BotUsers')
           or (n.nspname = 'public' and c.relname = 'Carriers')
           or (n.nspname = 'public' and c.relname = 'ContractCarrier')
           or (n.nspname = 'public' and c.relname = 'ContractMaterial')
           or (n.nspname = 'public' and c.relname = 'Contracts')
           or (n.nspname = 'public' and c.relname = 'SystemNames'))

         and ((nf.nspname = 'public' and cf.relname = 'BotUsers')
           or (nf.nspname = 'public' and cf.relname = 'Carriers')
           or (nf.nspname = 'public' and cf.relname = 'ContractCarrier')
           or (nf.nspname = 'public' and cf.relname = 'ContractMaterial')
           or (nf.nspname = 'public' and cf.relname = 'Contracts')
           or (nf.nspname = 'public' and cf.relname = 'SystemNames'))

2025-11-05T02:33:59.595989Z SQL -- params pkey-oid-list
--        fkey-oild-list
with pkeys(oid) as (
  values(16768),(16792),(16876),(16845),(16877),(16878),(16879),(16864),(16880),(16882),(16826),(16881),(16783)
),
     knownfkeys(oid) as (
  values(16794),(16847),(16852),(16866),(16828),(16833)
),
  pkdeps as (
  select pkeys.oid, pg_depend.objid
    from pg_depend
         join pkeys on pg_depend.refobjid = pkeys.oid
   where     classid = 'pg_catalog.pg_constraint'::regclass
         and refclassid = 'pg_catalog.pg_class'::regclass
)
 select n.nspname, c.relname, nf.nspname, cf.relname as frelname,
        r.oid as conoid, conname,
        pg_catalog.pg_get_constraintdef(r.oid, true) as condef,
        pkdeps.oid as index_oid
   from pg_catalog.pg_constraint r
        JOIN pkdeps on r.oid = pkdeps.objid
        JOIN pg_class c on r.conrelid = c.oid
        JOIN pg_namespace n on c.relnamespace = n.oid
        JOIN pg_class cf on r.confrelid = cf.oid
        JOIN pg_namespace nf on cf.relnamespace = nf.oid
  where NOT EXISTS (select 1 from knownfkeys where oid = r.oid)
2025-11-05T02:33:59.603989Z DEBUG fetch-pgsql-catalog: 6 tables, 13 indexes, 6+6 fkeys
2025-11-05T02:33:59.603989Z WARNING Source column "public"."BotUsers"."\"OwnerId\"" is casted to type "text" which is not the same as "character varying", the type of current target database column "public"."BotUsers"."OwnerId".
2025-11-05T02:33:59.603989Z WARNING Source column "public"."Carriers"."\"Name\"" is casted to type "text" which is not the same as "character varying", the type of current target database column "public"."Carriers"."Name".
2025-11-05T02:33:59.603989Z WARNING Source column "public"."Carriers"."\"Tag\"" is casted to type "text" which is not the same as "character varying", the type of current target database column "public"."Carriers"."Tag".
2025-11-05T02:33:59.603989Z WARNING Source column "public"."Contracts"."\"OwnerId\"" is casted to type "text" which is not the same as "character varying", the type of current target database column "public"."Contracts"."OwnerId".
2025-11-05T02:33:59.603989Z WARNING Source column "public"."Contracts"."\"ThreadTitle\"" is casted to type "text" which is not the same as "character varying", the type of current target database column "public"."Contracts"."ThreadTitle".
2025-11-05T02:33:59.603989Z WARNING Source column "public"."Contracts"."\"OtherDetails\"" is casted to type "text" which is not the same as "character varying", the type of current target database column "public"."Contracts"."OtherDetails".
2025-11-05T02:33:59.603989Z WARNING Source column "public"."SystemNames"."\"Name\"" is casted to type "text" which is not the same as "character varying", the type of current target database column "public"."SystemNames"."Name".
2025-11-05T02:33:59.623989Z NOTICE ALTER TABLE "public"."Carriers" DROP CONSTRAINT IF EXISTS "FK_Carriers_BotUsers_BotUserId" CASCADE;
2025-11-05T02:33:59.627989Z NOTICE ALTER TABLE "public"."Contracts" DROP CONSTRAINT IF EXISTS "FK_Contracts_BotUsers_BotUserId" CASCADE;
2025-11-05T02:33:59.627989Z NOTICE ALTER TABLE "public"."Carriers" DROP CONSTRAINT IF EXISTS "FK_Carriers_BotUsers_BotUserId" CASCADE;
2025-11-05T02:33:59.631989Z WARNING PostgreSQL warning: constraint "FK_Carriers_BotUsers_BotUserId" of relation "Carriers" does not exist, skipping
2025-11-05T02:33:59.631989Z NOTICE ALTER TABLE "public"."ContractCarrier" DROP CONSTRAINT IF EXISTS "FK_ContractCarrier_Carriers_CarrierId" CASCADE;
2025-11-05T02:33:59.631989Z NOTICE ALTER TABLE "public"."ContractCarrier" DROP CONSTRAINT IF EXISTS "FK_ContractCarrier_Carriers_CarrierId" CASCADE;
2025-11-05T02:33:59.631989Z WARNING PostgreSQL warning: constraint "FK_ContractCarrier_Carriers_CarrierId" of relation "ContractCarrier" does not exist, skipping
2025-11-05T02:33:59.631989Z NOTICE ALTER TABLE "public"."ContractCarrier" DROP CONSTRAINT IF EXISTS "FK_ContractCarrier_Contracts_ContractId" CASCADE;
2025-11-05T02:33:59.635989Z NOTICE ALTER TABLE "public"."ContractMaterial" DROP CONSTRAINT IF EXISTS "FK_ContractMaterial_Contracts_ContractId" CASCADE;
2025-11-05T02:33:59.635989Z NOTICE ALTER TABLE "public"."Contracts" DROP CONSTRAINT IF EXISTS "FK_Contracts_BotUsers_BotUserId" CASCADE;
2025-11-05T02:33:59.635989Z WARNING PostgreSQL warning: constraint "FK_Contracts_BotUsers_BotUserId" of relation "Contracts" does not exist, skipping
2025-11-05T02:33:59.635989Z NOTICE ALTER TABLE "public"."Contracts" DROP CONSTRAINT IF EXISTS "FK_Contracts_SystemNames_SystemNameId" CASCADE;
2025-11-05T02:33:59.639989Z NOTICE ALTER TABLE "public"."ContractCarrier" DROP CONSTRAINT IF EXISTS "FK_ContractCarrier_Contracts_ContractId" CASCADE;
2025-11-05T02:33:59.639989Z WARNING PostgreSQL warning: constraint "FK_ContractCarrier_Contracts_ContractId" of relation "ContractCarrier" does not exist, skipping
2025-11-05T02:33:59.639989Z NOTICE ALTER TABLE "public"."ContractMaterial" DROP CONSTRAINT IF EXISTS "FK_ContractMaterial_Contracts_ContractId" CASCADE;
2025-11-05T02:33:59.639989Z WARNING PostgreSQL warning: constraint "FK_ContractMaterial_Contracts_ContractId" of relation "ContractMaterial" does not exist, skipping
2025-11-05T02:33:59.639989Z NOTICE ALTER TABLE "public"."Contracts" DROP CONSTRAINT IF EXISTS "FK_Contracts_SystemNames_SystemNameId" CASCADE;
2025-11-05T02:33:59.639989Z WARNING PostgreSQL warning: constraint "FK_Contracts_SystemNames_SystemNameId" of relation "Contracts" does not exist, skipping
2025-11-05T02:33:59.791989Z NOTICE COPY public."BotUsers" with 0 rows estimated [3/4]
2025-11-05T02:33:59.795989Z DEBUG Reader started for public."BotUsers"
2025-11-05T02:33:59.815989Z DEBUG start public."BotUsers"   2575984
2025-11-05T02:33:59.815989Z NOTICE COPY public."Carriers" with 0 rows estimated [2/4]
2025-11-05T02:33:59.815989Z DEBUG Reader started for public."Carriers"
2025-11-05T02:33:59.819988Z DEBUG start public."Carriers"   2579984
2025-11-05T02:33:59.819988Z INFO COPY ON ERROR STOP
2025-11-05T02:33:59.819988Z INFO COPY ON ERROR STOP
Max connections reached, increase value of TDS_MAX_CONN
2025-11-05T02:33:59.863988Z DEBUG SELECT cast([Id] as numeric(20)), [Name], [Tag], cast([BotUserId] as numeric(20)) FROM [dbo].[Carriers];
Max connections reached, increase value of TDS_MAX_CONN
2025-11-05T02:33:59.871988Z DEBUG Reader for public."Carriers" is done in 0.075999s
2025-11-05T02:33:59.875988Z INFO COPY ON ERROR STOP
2025-11-05T02:33:59.875988Z DEBUG Finished processing READER for "public.\"Carriers\""  0.075999s
2025-11-05T02:33:59.879988Z DEBUG SELECT cast([Id] as numeric(20)), [OwnerId], [OwnerDiscordId] FROM [dbo].[BotUsers];
2025-11-05T02:33:59.883988Z DEBUG Reader for public."BotUsers" is done in 0.091999s
2025-11-05T02:33:59.883988Z DEBUG Finished processing READER for "public.\"BotUsers\""  0.091999s
2025-11-05T02:33:59.883988Z NOTICE COPY public."ContractCarrier" with 0 rows estimated [3/4]
2025-11-05T02:33:59.883988Z DEBUG Reader started for public."ContractCarrier"
2025-11-05T02:33:59.883988Z DEBUG start public."ContractCarrier"   2667983
Max connections reached, increase value of TDS_MAX_CONN
2025-11-05T02:33:59.927988Z DEBUG SELECT cast([Id] as numeric(20)), cast([ContractId] as numeric(20)), cast([CarrierId] as numeric(20)) FROM [dbo].[ContractCarrier];
2025-11-05T02:33:59.931988Z DEBUG Reader for public."ContractCarrier" is done in 0.048000s
2025-11-05T02:33:59.935988Z NOTICE COPY public."Contracts" with 0 rows estimated [3/4]
2025-11-05T02:33:59.935988Z DEBUG Reader started for public."Contracts"
2025-11-05T02:33:59.935988Z DEBUG start public."Contracts"   2715983
2025-11-05T02:33:59.935988Z DEBUG Finished processing READER for "public.\"ContractCarrier\""  0.048000s
Max connections reached, increase value of TDS_MAX_CONN
2025-11-05T02:33:59.979987Z DEBUG SELECT cast([Id] as numeric(20)), [OwnerId], [Status], [ConstructionTier], [ConstructionType], [WorkflowType], [TonnageRequired], [IsPrimary], convert(varchar(30), [ConstructionExpiry], 126), [ThreadTitle], [OtherDetails], cast([SystemNameId] as numeric(20)), convert(varchar(30), [CreatedDate], 126), convert(varchar(30), [SubmittedDate], 126), convert(varchar(30), [ReviewedDate], 126), convert(varchar(30), [StartedDate], 126), convert(varchar(30), [CompletedDate], 126), [ThreadId], convert(varchar(30), [CancelledDate], 126), [CarrierJobType], cast([BotUserId] as numeric(20)) FROM [dbo].[Contracts];
2025-11-05T02:33:59.983987Z DEBUG Reader for public."Contracts" is done in 0.051999s
2025-11-05T02:33:59.983987Z DEBUG Finished processing READER for "public.\"Contracts\""  0.051999s
2025-11-05T02:33:59.987987Z INFO COPY ON ERROR STOP
2025-11-05T02:34:00.103987Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {100AA203C3}>
2025-11-05T02:34:00.103987Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.103987Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.107987Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.107987Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:00.107987Z SQL SET search_path TO public;
2025-11-05T02:34:00.111987Z INFO pgsql:copy-rows-from-queue[1]: public."BotUsers" ("Id" "OwnerId"
                                                  "OwnerDiscordId")
2025-11-05T02:34:00.115987Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {100AA206B3}>
2025-11-05T02:34:00.119987Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.119987Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.119987Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.119987Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:00.123987Z SQL SET search_path TO public;
2025-11-05T02:34:00.123987Z INFO pgsql:copy-rows-from-queue[0]: public."Carriers" ("Id" "Name" "Tag" "BotUserId")
2025-11-05T02:34:00.147986Z DEBUG  stop public."Carriers"   | 2579984 .. 2931981 = 0.351997d0
2025-11-05T02:34:00.151986Z DEBUG Writer[0] for public."Carriers" is done in 0.000000s
2025-11-05T02:34:00.151986Z DEBUG Finished processing WRITER for "public.\"Carriers\""  0.000000s
2025-11-05T02:34:00.151986Z DEBUG writers-counts[public."Carriers"] = 0
2025-11-05T02:34:00.151986Z INFO COPY ON ERROR STOP
2025-11-05T02:34:00.183986Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {100AA20163}>
2025-11-05T02:34:00.183986Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.183986Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.187986Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.187986Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:00.191986Z SQL SET search_path TO public;
2025-11-05T02:34:00.191986Z INFO pgsql:copy-rows-from-queue[2]: public."ContractCarrier" ("Id" "ContractId"
                                                         "CarrierId")
2025-11-05T02:34:00.195986Z DEBUG  stop public."ContractCarrier"   | 2667983 .. 2979981 = 0.311998d0
2025-11-05T02:34:00.203986Z DEBUG Writer[2] for public."ContractCarrier" is done in 0.000000s
2025-11-05T02:34:00.203986Z INFO COPY ON ERROR STOP
2025-11-05T02:34:00.203986Z DEBUG Finished processing WRITER for "public.\"ContractCarrier\""  0.000000s
2025-11-05T02:34:00.203986Z DEBUG writers-counts[public."ContractCarrier"] = 0
2025-11-05T02:34:00.239985Z DEBUG  stop public."BotUsers"   | 2575984 .. 3023980 = 0.447996d0
2025-11-05T02:34:00.247985Z DEBUG Writer[1] for public."BotUsers" is done in 0.000000s
2025-11-05T02:34:00.247985Z NOTICE COPY public."ContractMaterial" with 0 rows estimated [1/4]
2025-11-05T02:34:00.247985Z DEBUG Reader started for public."ContractMaterial"
2025-11-05T02:34:00.247985Z DEBUG start public."ContractMaterial"   3027980
2025-11-05T02:34:00.247985Z DEBUG Finished processing WRITER for "public.\"BotUsers\""  0.000000s
2025-11-05T02:34:00.247985Z DEBUG writers-counts[public."BotUsers"] = 0
2025-11-05T02:34:00.279984Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {100AA20053}>
2025-11-05T02:34:00.279984Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.279984Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.283984Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.283984Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:00.287984Z SQL SET search_path TO public;
2025-11-05T02:34:00.287984Z INFO pgsql:copy-rows-from-queue[3]: public."ContractMaterial" ("Id" "TonsRequired"
                                                          "ProfitPerTon"
                                                          "MaterialId"
                                                          "ContractId")
Max connections reached, increase value of TDS_MAX_CONN
2025-11-05T02:34:00.295984Z DEBUG SELECT cast([Id] as numeric(20)), [TonsRequired], [ProfitPerTon], cast([MaterialId] as numeric(20)), cast([ContractId] as numeric(20)) FROM [dbo].[ContractMaterial];
2025-11-05T02:34:00.299984Z DEBUG Reader for public."ContractMaterial" is done in 0.055999s
2025-11-05T02:34:00.299984Z NOTICE COPY public."SystemNames" with 0 rows estimated [1/4]
2025-11-05T02:34:00.299984Z DEBUG Reader started for public."SystemNames"
2025-11-05T02:34:00.303984Z DEBUG start public."SystemNames"   3083979
2025-11-05T02:34:00.303984Z DEBUG Finished processing READER for "public.\"ContractMaterial\""  0.055999s
Max connections reached, increase value of TDS_MAX_CONN
2025-11-05T02:34:00.343984Z DEBUG SELECT cast([Id] as numeric(20)), [Name] FROM [dbo].[SystemNames];
2025-11-05T02:34:00.347984Z DEBUG Reader for public."SystemNames" is done in 0.048000s
2025-11-05T02:34:00.347984Z DEBUG Finished processing READER for "public.\"SystemNames\""  0.048000s
2025-11-05T02:34:00.411984Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {1007DE4A23}>
2025-11-05T02:34:00.411984Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.411984Z DEBUG  stop public."ContractMaterial"   | 3027980 .. 3195979 = 0.167999d0
2025-11-05T02:34:00.411984Z DEBUG Writer[3] for public."ContractMaterial" is done in 0.000000s
2025-11-05T02:34:00.415984Z DEBUG Finished processing WRITER for "public.\"ContractMaterial\""  0.000000s
2025-11-05T02:34:00.415984Z DEBUG writers-counts[public."ContractMaterial"] = 0
2025-11-05T02:34:00.415984Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.419984Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.419984Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:00.423984Z SQL SET search_path TO public;
2025-11-05T02:34:00.423984Z INFO pgsql:copy-rows-from-queue[0]: public."SystemNames" ("Id" "Name")
2025-11-05T02:34:00.443983Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {10080A4B23}>
2025-11-05T02:34:00.447983Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.447983Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.447983Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.447983Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:00.447983Z SQL SET search_path TO public;
2025-11-05T02:34:00.451983Z INFO pgsql:copy-rows-from-queue[2]: public."Contracts" ("Id" "OwnerId" "Status"
                                                   "ConstructionTier"
                                                   "ConstructionType"
                                                   "WorkflowType"
                                                   "TonnageRequired"
                                                   "IsPrimary"
                                                   "ConstructionExpiry"
                                                   "ThreadTitle" "OtherDetails"
                                                   "SystemNameId" "CreatedDate"
                                                   "SubmittedDate"
                                                   "ReviewedDate" "StartedDate"
                                                   "CompletedDate" "ThreadId"
                                                   "CancelledDate"
                                                   "CarrierJobType" "BotUserId")
2025-11-05T02:34:00.531983Z DEBUG  stop public."SystemNames"   | 3083979 .. 3315978 = 0.231999d0
2025-11-05T02:34:00.531983Z DEBUG Writer[0] for public."SystemNames" is done in 0.000000s
2025-11-05T02:34:00.535983Z DEBUG Finished processing WRITER for "public.\"SystemNames\""  0.000000s
2025-11-05T02:34:00.535983Z DEBUG writers-counts[public."SystemNames"] = 0
2025-11-05T02:34:00.631982Z DEBUG  stop public."Contracts"   | 2715983 .. 3415977 = 0.699994d0
2025-11-05T02:34:00.631982Z DEBUG Writer[2] for public."Contracts" is done in 0.000000s
2025-11-05T02:34:00.635982Z DEBUG Finished processing WRITER for "public.\"Contracts\""  0.000000s
2025-11-05T02:34:00.635982Z DEBUG writers-counts[public."Contracts"] = 0
2025-11-05T02:34:00.635982Z INFO Done with COPYing data, waiting for indexes
2025-11-05T02:34:00.675982Z NOTICE Completing PostgreSQL database.
2025-11-05T02:34:00.675982Z NOTICE Reset sequences
2025-11-05T02:34:00.867982Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {1009D7EA63}>
2025-11-05T02:34:00.867982Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.871982Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.871982Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.871982Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:00.871982Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:00.875982Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:00.875982Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:00.875982Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:01.203979Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {100A467C63}>
2025-11-05T02:34:01.203979Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:01.203979Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:01.203979Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:01.203979Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:01.207979Z DEBUG BEGIN
2025-11-05T02:34:01.219978Z DEBUG EXTRA FK DEPS! ALTER TABLE "public"."Carriers" ADD CONSTRAINT "FK_Carriers_BotUsers_BotUserId" FOREIGN KEY ("BotUserId") REFERENCES "BotUsers"("Id")
2025-11-05T02:34:01.219978Z DEBUG EXTRA FK DEPS! ALTER TABLE "public"."Contracts" ADD CONSTRAINT "FK_Contracts_BotUsers_BotUserId" FOREIGN KEY ("BotUserId") REFERENCES "BotUsers"("Id")
2025-11-05T02:34:01.219978Z DEBUG EXTRA FK DEPS! ALTER TABLE "public"."ContractCarrier" ADD CONSTRAINT "FK_ContractCarrier_Carriers_CarrierId" FOREIGN KEY ("CarrierId") REFERENCES "Carriers"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.223978Z DEBUG EXTRA FK DEPS! ALTER TABLE "public"."ContractCarrier" ADD CONSTRAINT "FK_ContractCarrier_Contracts_ContractId" FOREIGN KEY ("ContractId") REFERENCES "Contracts"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.223978Z DEBUG EXTRA FK DEPS! ALTER TABLE "public"."ContractMaterial" ADD CONSTRAINT "FK_ContractMaterial_Contracts_ContractId" FOREIGN KEY ("ContractId") REFERENCES "Contracts"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.223978Z DEBUG EXTRA FK DEPS! ALTER TABLE "public"."Contracts" ADD CONSTRAINT "FK_Contracts_SystemNames_SystemNameId" FOREIGN KEY ("SystemNameId") REFERENCES "SystemNames"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.223978Z NOTICE ALTER TABLE "public"."Carriers" ADD CONSTRAINT "FK_Carriers_BotUsers_BotUserId" FOREIGN KEY ("BotUserId") REFERENCES "BotUsers"("Id")
2025-11-05T02:34:01.227978Z NOTICE ALTER TABLE "public"."ContractCarrier" ADD CONSTRAINT "FK_ContractCarrier_Carriers_CarrierId" FOREIGN KEY ("CarrierId") REFERENCES "Carriers"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.231978Z NOTICE ALTER TABLE "public"."ContractCarrier" ADD CONSTRAINT "FK_ContractCarrier_Contracts_ContractId" FOREIGN KEY ("ContractId") REFERENCES "Contracts"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.235978Z NOTICE ALTER TABLE "public"."ContractMaterial" ADD CONSTRAINT "FK_ContractMaterial_Contracts_ContractId" FOREIGN KEY ("ContractId") REFERENCES "Contracts"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.239978Z NOTICE ALTER TABLE "public"."Contracts" ADD CONSTRAINT "FK_Contracts_BotUsers_BotUserId" FOREIGN KEY ("BotUserId") REFERENCES "BotUsers"("Id")
2025-11-05T02:34:01.243978Z NOTICE ALTER TABLE "public"."Contracts" ADD CONSTRAINT "FK_Contracts_SystemNames_SystemNameId" FOREIGN KEY ("SystemNameId") REFERENCES "SystemNames"("Id") ON DELETE CASCADE
2025-11-05T02:34:01.367977Z NOTICE Executing SQL block for after load
2025-11-05T02:34:01.583976Z DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://sccn-job-bot-stage@localhost:5432/sccn-bot-stage {100A8C2393}>
2025-11-05T02:34:01.583976Z DEBUG SET client_encoding TO 'utf8'
2025-11-05T02:34:01.583976Z DEBUG SET work_mem TO '16MB'
2025-11-05T02:34:01.583976Z DEBUG SET maintenance_work_mem TO '512 MB'
2025-11-05T02:34:01.583976Z DEBUG SET application_name TO 'pgloader'
2025-11-05T02:34:01.587976Z DEBUG BEGIN
2025-11-05T02:34:01.587976Z SQL GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "sccn-job-bot-stage";
2025-11-05T02:34:01.695975Z LOG report summary reset
               table name     errors       read   imported      bytes      total time       read      write
-------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
          fetch meta data          0         13         13                     0.460s
        Drop Foreign Keys          0         12         12                     0.036s
-------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
        public."BotUsers"          0          1          1     0.0 kB          0.448s     0.092s
        public."Carriers"          0          0          0                     0.352s     0.076s
 public."ContractCarrier"          0          0          0                     0.312s     0.048s
       public."Contracts"          0         11         11     2.7 kB          0.700s     0.052s
public."ContractMaterial"          0          6          6     0.1 kB          0.168s     0.056s
     public."SystemNames"          0          8          8     0.1 kB          0.232s     0.048s
-------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
  COPY Threads Completion          0          4          4                     0.828s
          Reset Sequences          0          0          0                     0.324s
      Create Foreign Keys          0          6          6                     0.028s
         Install Comments          0          0          0                     0.000s
               after load          0          1          1                     0.328s
-------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
        Total import time          ✓         26         26     2.9 kB          1.508s
2025-11-05T02:34:01.811975Z INFO Stopping monitor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions