title: Handling access privilege in liquibase with postgres
body: <p>I am new to liquibase. I am using the <a href="https://docs.liquibase.com/concepts/changelogs/sql-format.html?_ga=2.247478853.375258907.1660800010-1391885298.1660493357" rel="nofollow noreferrer">sql formatted changelogs</a> 1 for postgres RDS. We run liquibase using <code>masteruser</code> in postgres and the application accesses the database using a different user in postgres, <code>appsuer</code>.</p>
  <p>If I am creating a new table in database via liquibase. The <code>appuser</code> do not have the privilege to access the new table. So every time, I have to execute the below command as <code>masteruser</code> on the app DB after a new table is created.</p>
  <pre><code>GRANT SELECT, INSERT, UPDATE, REFERENCES, TRIGGER ON ALL TABLES IN SCHEMA public TO appsuer;
  </code></pre>
  <p>Can someone let me know how to handle the <code>GRANT</code> also via liquibase SQL formatted changelogs or there are some other simpler and recommended ways? We only have two users in the database as mentioned here.</p>
  <p>I executed the below command as <code>masteruser</code> on the app DB.</p>
  <pre><code>GRANT appuser to masteruser;
  ALTER DEFAULT PRIVILEGES
      FOR USER appuser
      IN SCHEMA public
      GRANT SELECT, INSERT, UPDATE, REFERENCES, TRIGGER ON ALL TABLES IN SCHEMA public TO appsuer ;
  
  </code></pre>
  <p>But then each time a new table is created via liquibase I have to execute the <code>GRANT</code> command once again inspite of <code>ALTER DEFAULT PRIVILEGE</code> command being executed.</p>