title: Getting started with Flyway and an existing PostgreSQL database
body: <p>I read the article related to <a href="https://flywaydb.org/documentation/existing" rel="nofollow noreferrer">Existing database setup</a> but I still didn't get it.</p>
  
  <p>I already have a postgresql database with a lot of data, and I would like to have a migration tool to keep track of my database schema. From what I understand from that link (in my case, using postgresql) I just have to do "pg_dump -s ..." (which will dump schemas, tables, ... but not data from tables, in sql format), name it as "V1__Baseline_version.sql" and add it to the /sql directory. This will be the baseline version for my existent database:</p>
  
  <pre><code>$ flyway baseline -Dflyway.baselineVersion=1 -Dflyway.baselineDescription="Base version"
  </code></pre>
  
  <p>The above command will create an additional table in my database to keep track of migrations.</p>
  
  <p><strong>Note:</strong> I don't want to add any reference data, just to keep track of db schema changes</p>
  
  <p>Now, any new changes to my schema should be added for example to /sql/V2__Add_some_changes.sql and run:</p>
  
  <pre><code>$ flyway migrate
  </code></pre>
  
  <p>and this will migrate my existing database to V2.</p>
  
  <p>... and so on, V3 ...Vx</p>
  
  <p>Can somebody confirm that it is the right approach?</p>
  
  <p>Edit: one more question: Having multiple machines, development/testing/staging/production I can use the same set of sql scripts (stored in one common /sql) to keep their db schema in "sync", and just do for each: "flyway baseline ..." + "flyway migrate".</p>