liquibase 如何确定,应该应用哪些更改?

How liquibase determines, what changes should be applied?

我是 liquibase 的新手,我已经阅读了 liquibase 文档,但仍然没有找到,liquibase 如何确定数据库的当前版本以及应在 update 上应用哪些更改。

例如,如果考虑来自 liquibase 站点主页的 SQL 脚本:

update、sql 文件的第一个 运行 是:

--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)
);

update的第二个运行,剧本是

--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)

第三个运行是:

--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)

第 4 运行:

--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)

第 5 个 运行 是:

--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)

第 5 天会发生什么 update 运行 以及 liquibase 将如何确定,第 4 天后 运行 数据库版本将为“4”,需要将列修改为 15 个字符长度?

可能是,liquibase 在数据库中添加了一些 "version" table,它插入了应用的最新版本 changeset/patch?

谢谢!

http://www.liquibase.org/documentation/index.html 说:

Change Sets are uniquely identified by the "author" and "id" attribute along with with the location of the changelog file and are the units Liquibase tracks execution of. When Liquibase runs, it queries the DATABASECHANGELOG table for the changesets that are marked as executed and then executes all changesets in the changelog file that have not yet been executed.