CREATETABLE person ( id integerNOTNULL, name varchar(100) NOTNULL, PRIMARY KEY (id) );
Migrating the database
1 2 3 4 5 6 7 8 9
# flyway migrate
Flyway Community Edition 6.3.2 by Redgate Database: jdbc:postgresql://localhost:5432/pcc (PostgreSQL 12.1) Successfully validated 1 migration (execution time 00:00.022s) Creating Schema History table "public"."flyway_schema_history" ... Current version of schema "public": << Empty Schema >> Migrating schema "public" to version 1 - Create person table Successfully applied 1 migration to schema "public" (execution time 00:00.068s)
Adding a second migration
vi sql/V2__Add_people.sql
1 2 3
INSERTINTO person (id, name) VALUES (1, 'Axel'); INSERTINTO person (id, name) VALUES (2, 'Mr. Foo'); INSERTINTO person (id, name) VALUES (3, 'Ms. Bar');
Migrating the database again
1 2 3 4 5 6 7
# flyway migrate Flyway Community Edition 6.3.2 by Redgate Database: jdbc:postgresql://localhost:5432/pcc (PostgreSQL 12.1) Successfully validated 2 migrations (execution time 00:00.065s) Current version of schema "public": 1 Migrating schema "public" to version 2 - Add people Successfully applied 1 migration to schema "public" (execution time 00:00.106s)
Flyway schema history table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# \d flyway_schema_history Table "public.flyway_schema_history" Column | Type | Collation | Nullable | Default ----------------+-----------------------------+-----------+----------+--------- installed_rank | integer | | not null | version | character varying(50) | | | description | character varying(200) | | not null | type | character varying(20) | | not null | script | character varying(1000) | | not null | checksum | integer | | | installed_by | character varying(100) | | not null | installed_on | timestamp without time zone | | not null | now() execution_time | integer | | not null | success | boolean | | not null | Indexes: "flyway_schema_history_pk" PRIMARY KEY, btree (installed_rank) "flyway_schema_history_s_idx" btree (success)