title: Postgresql forgets grants after recreating tables
body: <p>We use liquibase to manage and execute our database changes. On our DEV environment (and especially on local machines) we frequently recreate the tables to have a clean slate.
  We have just migrated from MySQL to Postgres and are facing a problem related to these table recreations.</p>
  
  <p>Initially we have granted our DB user with this:</p>
  
  <pre><code>GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA public TO mydbuser;
  GRANT SELECT, USAGE ON ALL SEQUENCES IN SCHEMA public TO mydbuser;
  </code></pre>
  
  <p>This is executed through <em>psql</em> after connecting to our own DB (where public is the default/only schema).</p>
  
  <p>Everything is fine until we ask liquibase to recreate the tables in which case it will drop all tables and create them again.</p>
  
  <p>After that it appears that <em>mydbuser</em> has lost all its grants on the tables.</p>
  
  <p>According to several resources (like <a href="http://www.postgresql.org/docs/9.0/static/sql-alterdefaultprivileges.html" rel="noreferrer">this</a>) we need to alter the default privileges, so we obey: </p>
  
  <pre><code>GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA public TO mydbuser;
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT,INSERT,UPDATE,DELETE ON TABLES TO mydbuser;
  
  GRANT SELECT, USAGE ON ALL SEQUENCES IN SCHEMA public TO mydbuser;
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, USAGE ON SEQUENCES TO mydbuser;
  </code></pre>
  
  <p>However, although this seems very logical it changed nothing. All grants (even select) are still lost after recreating the tables.</p>
  
  <p>What are we doing wrong or what else do we need to do?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>\ddp shows:
               Default access privileges</p>
  
  <blockquote>
    <p>Owner   | Schema |   Type   | Access privileges<br>
    ----------+--------+----------+--------------------<br>
       postgres | public | sequence | mydb=rU/postgres<br>
       postgres | public | table    | mydb=arwd/postgres</p>
  </blockquote>