title: How liquibase determines, what changes should be applied?
body: <p>I am newbie in liquibase, I've read liquibase docs, but still didn't find, how liquibase determines current version of the DB and what changes should be applied on <code>update</code>.</p>
  
  <p>For example, if to consider SQL script from liquibase site main page:</p>
  
  <p>First run of the <code>update</code>, sql file is:</p>
  
  <pre><code>--liquibase formatted sql
  
  --changeset nvoxland:1
  create table person (
    id int not null primary key,
    firstname varchar(80),
    lastname varchar(80) not null,
    state varchar(2)
  );
  </code></pre>
  
  <p>Second run of the <code>update</code>, the script is </p>
  
  <pre><code>--liquibase formatted sql
  
  --changeset nvoxland:1
  create table person (
    id int not null primary key,
    firstname varchar(80),
    lastname varchar(80) not null,
    state varchar(2)
  );
  
  --changeset nvoxland:2
  alter table person MODIFY column firstname varchar(8)
  </code></pre>
  
  <p>Third run is:</p>
  
  <pre><code>--liquibase formatted sql
  
  --changeset nvoxland:1
  create table person (
    id int not null primary key,
    firstname varchar(80),
    lastname varchar(80) not null,
    state varchar(2)
  );
  
  --changeset nvoxland:2
  alter table person MODIFY column firstname varchar(8)
  
  --changeset nvoxland:3
  alter table person MODIFY column firstname varchar(10)
  </code></pre>
  
  <p>4th run:</p>
  
  <pre><code>--liquibase formatted sql
  
  --changeset nvoxland:1
  create table person (
    id int not null primary key,
    firstname varchar(80),
    lastname varchar(80) not null,
    state varchar(2)
  );
  
  --changeset nvoxland:2
  alter table person MODIFY column firstname varchar(8)
  
  --changeset nvoxland:3
  alter table person MODIFY column firstname varchar(10)
  
  --changeset nvoxland:4
  alter table person MODIFY column firstname varchar(8)
  </code></pre>
  
  <p>5th run is:</p>
  
  <pre><code>--liquibase formatted sql
  
  --changeset nvoxland:1
  create table person (
    id int not null primary key,
    firstname varchar(80),
    lastname varchar(80) not null,
    state varchar(2)
  );
  
  --changeset nvoxland:2
  alter table person MODIFY column firstname varchar(8)
  
  --changeset nvoxland:3
  alter table person MODIFY column firstname varchar(10)
  
  --changeset nvoxland:4
  alter table person MODIFY column firstname varchar(8)
  
  --changeset nvoxland:5
  alter table person MODIFY column firstname varchar(15)
  </code></pre>
  
  <p>What will be happened on 5th <code>update</code> run and how liquibase will determine, that after 4th run database version will be "4" and need to modify column to 15 chars length?</p>
  
  <p>May be, liquibase adds some "version" table to the database, where it inserts the latest version of the applied changeset/patch?</p>
  
  <p>Thank you!</p>