Hi @aya,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
It is generally not recommended to have multiple owners for a table in PostgreSQL, as it can lead to confusion and potential conflicts. Instead, you can consider using a different approach to manage table ownership and access control.
You can try with PostgreSQL Roles with Inheritance, Set up a role that has the required permissions on tables and make both liquibase and claimroot members of this role. This way, liquibase can create and modify tables with permissions inherited from the role.
CREATE ROLE table_manager_role;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA your_schema TO table_manager_role;
GRANT table_manager_role TO liquibase;
GRANT table_manager_role TO claimroot;
Either, you can dynamically change the table ownership, you can use a PostgreSQL function that takes the table name and new owner as parameters, and executes the ALTER TABLE statement to change the ownership.
For example:
CREATE FUNCTION change_table_owner(tablename text, newowner text) RETURNS void AS $$
BEGIN
EXECUTE 'ALTER TABLE ' || quote_ident(tablename) || ' OWNER TO ' || quote_ident(newowner);
END;
$$ LANGUAGE plpgsql;
You can then grant the EXECUTE privilege on this function to the liquibase role, so that it can change the ownership of the tables dynamically.
GRANT EXECUTE ON FUNCTION change_table_owner TO liquibase;
I hope, This response will address your query and helped you to overcome on your challenges.
If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.