Error actualizacion de 4.1.0 a 4.2.0 (RESPONDIDO)

Buenas!Estamos actualizando Diaguita desde 4.1.0 a 4.2.0.al momento de actualizar, nos da el siguiente error:

PHP Fatal error: Uncaught Exception: Error realizando la migración. No se pudo realizar la conversión de la base de datos para la versión 4.2.0, ejecutando el archivo de conversión /srv/SIU-Diaguita-4.2.0.1_testing/sql/repositorio_conversion/4.2.0.sql SQL ERROR: SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: sequence must have same owner as table it is linked to SET CONSTRAINTS ALL IMMEDIATE; SET search_path = diaguita; SET client_encoding = ‘LATIN1’; INSERT INTO par_version (descripcion, fecha) VALUES (‘4.2.0’,now()); /* #50603 / INSERT INTO diaguita.anx_codigos_postales VALUES (‘1914’, 50410) ON CONFLICT (codigo_postal,localidad) DO NOTHING; / #50525 */ SET search_path=ofertas; – SEQUENCE: ofertas.adjuntos_oferta_id_adjunto_oferta_seq – DROP SEQUENCE IF EXISTS ofertas.adjuntos_oferta_id_adjunto_oferta_seq; CREATE SEQUENCE IF NOT EXISTS ofertas.adjuntos_oferta_id_adjunto_oferta_seq INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1; ALTER SEQUENCE ofertas.adjuntos_oferta_id_adjunto_oferta_seq OWNED BY ofertas.renglones_ofertas.id_renglon_oferta; – Table: ofertas.adjuntos_oferta – DROP TABLE IF EXISTS ofertas.adjuntos_oferta; CREATE TABLE IF NOT EXISTS ofertas.adjuntos_… in /srv/SIU-Diaguita-4.2.0.1_testing/php/extension_toba/diaguita_modelo.php:344 Stack trace: #0 /srv/SIU-Diaguita-4.2.0.1_testing/php/extension_toba/diaguita_comando.php(1537): diaguita_modelo->migrar() #1 /srv/SIU-Diaguita-4.2.0.1_testing/vendor/siu-toba/framework/php/consola/comandos/comando_proyecto.php(87): diaguita_comando->opcion__migrar() #2 /srv/SIU-Diaguita-4.2.0.1_testing/vendor/siu-toba/framework/php/consola/comando.php(90): comando_proyecto->ejecutar_opcion() #3 /srv/SIU-Diaguita-4.2.0.1_testing/vendor/siu-toba/framework/php/consola/consola.php(78): comando->procesar() #4 /srv/SIU-Diaguita-4.2.0.1_testing/vendor/siu-toba/framework/php/consola/consola.php(55): consola->invocar_comando() #5 /srv/SIU-Diaguita-4.2.0.1_testing/vendor/siu-toba/framework/php/consola/run.php(32): consola->run() #6 /srv/SIU-Diaguita-4.2.0.1_testing/vendor/siu-toba/framework/bin/launcher.php(31): require_once(‘…’) #7 /srv/SIU-Diaguita-4.2.0.1_testing/vendor/siu-toba/framework/bin/toba(2): require_once(‘…’) #8 {main} thrown in /srv/SIU-Diaguita-4.2.0.1_testing/php/extension_toba/diaguita_modelo.php on line 344

En la base, la consulta que lo genera es la siguiente:

2026-01-29 09:12:52.034 -03 [401425] us_diaguita@diaguita_testing ERROR:  sequence must have same owner as table it is linked to
2026-01-29 09:12:52.034 -03 [401425] us_diaguita@diaguita_testing STATEMENT:
  SET CONSTRAINTS ALL IMMEDIATE;
  SET search_path = diaguita;
  SET client_encoding = ‘LATIN1’;
  INSERT INTO par_version (descripcion, fecha) VALUES (‘4.2.0’,now());
  /*
  #50603
  */
  INSERT INTO diaguita.anx_codigos_postales VALUES (‘1914’, 50410) ON CONFLICT (codigo_postal,localidad) DO NOTHING;
    /*
    #50525
    */

    SET search_path=ofertas;
    -- SEQUENCE: ofertas.adjuntos_oferta_id_adjunto_oferta_seq

    -- DROP SEQUENCE IF EXISTS ofertas.adjuntos_oferta_id_adjunto_oferta_seq;

    CREATE SEQUENCE IF NOT EXISTS ofertas.adjuntos_oferta_id_adjunto_oferta_seq
        INCREMENT 1
        START 1
        MINVALUE 1
        MAXVALUE 2147483647
        CACHE 1;

    ALTER SEQUENCE ofertas.adjuntos_oferta_id_adjunto_oferta_seq
        OWNED BY ofertas.renglones_ofertas.id_renglon_oferta;

    -- Table: ofertas.adjuntos_oferta

    -- DROP TABLE IF EXISTS ofertas.adjuntos_oferta;

    CREATE TABLE IF NOT EXISTS ofertas.adjuntos_oferta
    (
        id_adjunto_oferta integer NOT NULL DEFAULT nextval('ofertas.adjuntos_oferta_id_adjunto_oferta_seq'::regclass),
        id_oferta integer,        uid uuid NOT NULL,
        uid_arai_documentos uuid,
        fecha_creacion date NOT NULL,
        tipo_documento character varying(50) COLLATE pg_catalog."default",
        nombre character varying(255) COLLATE pg_catalog."default",
        estado character varying(2) COLLATE pg_catalog."default" NOT NULL,
        binario bytea,
        observaciones character varying(255) COLLATE pg_catalog."default",
        CONSTRAINT adjuntos_oferta_pkey PRIMARY KEY (id_adjunto_oferta),
            CONSTRAINT oe_oferta_fk FOREIGN KEY (id_oferta) REFERENCES ofertas.ofertas(id_oferta)
    );


    SET search_path = diaguita;

    /*
    #50853
    */
    SET search_path=ofertas;
    ALTER TABLE IF EXISTS ofertas.adjuntos_oferta
        ADD COLUMN numero integer DEFAULT null;

    ALTER TABLE IF EXISTS ofertas.adjuntos_oferta
        ADD COLUMN ejercicio integer DEFAULT null;

    ALTER TABLE IF EXISTS ofertas.adjuntos_oferta
        ADD COLUMN id_documento_exportacion integer DEFAULT null;

    SET search_path=diaguita;
    INSERT INTO scp_tipos_documentos_tipo_firma(tipo_documento, tipo_documento_descripcion, tipo_firma, id_tabla) VALUES ('AOE', 'Anexo Oferta Electrónica', 'firma', 2);

    --Numerador para adjuntos
    INSERT INTO scp_numeradores VALUES ('ADJUNTO_OE ', 'Adjunto oferta electrónica', 's', 'AOE');

2026-01-29 09:12:52.047 -03 [401425] us_diaguita@diaguita_testing LOG:  statement: ROLLBACK WORK

En concreto:

`ALTER SEQUENCE ofertas.adjuntos_oferta_id_adjunto_oferta_seq
    OWNED BY ofertas.renglones_ofertas.id_renglon_oferta;`

Alguna idea de porque pasa eso?

Hola Andres,
¿Como te va? Estas teniendo un problema de permisos con el usuario con el cual acceden a la base , específicamente con el esquema ofertas; recomendable correr la consulta que les paso a continuación para observar el alcance de los usuarios de postgres para los esquemas en la base de diaguita:

SELECT 
    n.nspname AS esquema,
    r.rolname AS usuario,
    CASE 
        WHEN has_schema_privilege(r.rolname, n.nspname, 'USAGE') THEN 'USAGE' 
        ELSE 'NONE' 
    END AS permiso_uso,
    CASE 
        WHEN has_schema_privilege(r.rolname, n.nspname, 'CREATE') THEN 'CREATE' 
        ELSE 'NONE' 
    END AS permiso_creacion,
    pg_catalog.pg_get_userbyid(n.nspowner) AS dueño_esquema
FROM 
    pg_catalog.pg_namespace n
CROSS JOIN 
    pg_catalog.pg_roles r
WHERE 
    n.nspname NOT LIKE 'pg_%' 
    AND n.nspname <> 'information_schema'
    AND r.rolcanlogin = true   
	AND n.nspname IN ('diaguita','ofertas')
ORDER BY 
    esquema, usuario;

En ese caso deben ser igual para poder realizar modificaciones tablas, campos y otros elementos de la base de datos.

Te dejo un enlace donde podes consultar el alcance de los roles y cual debe ser el apropiado para estos casos (CREATION)

Atributos de Roles en PostgreSQL

PD: En caso de cambiar el rol del usuario de postgres lo debe realizar el administrador del servidor de la base de datos.

Saludos!!!

Gracias por la resupesta!

El usuario parece tener los permisos correctos:

esquema | usuario | permiso_uso | permiso_creacion | dueño_esquema
----------±-----------------±------------±-----------------±--------------
diaguita | postgres | USAGE | CREATE | postgres
diaguita | us_dba | USAGE | CREATE | postgres
diaguita | us_diaguita | USAGE | CREATE | postgres
diaguita | us_pilaga | USAGE | CREATE | postgres
diaguita | us_pilaga_ro | NONE | NONE | postgres
ofertas | postgres | USAGE | CREATE | postgres
ofertas | us_dba | USAGE | CREATE | postgres
ofertas | us_diaguita | USAGE | CREATE | postgres
ofertas | us_pilaga | USAGE | CREATE | postgres
ofertas | us_pilaga_ro | NONE | NONE | postgres
(22 rows)

Por las dudas, veifique los atributos del usuario y es superusuario:


postgres=# \dg+ us_diaguita

                       List of roles
  Role name |      Attributes      | Member of | Description
------------±----------------------±-----------±-------------
us_diaguita | Superuser, Create DB | {}        |

Gracias!!!

COn el poder de una buena noche de descanso, resulta que el problema es que el usuario con el que ejecuto la instalacion (us_diaguita) no era dueño de los objetos dentro de la base a actualizar. Use esta respuesta de stackoverflow para reasignarlos: