2025-04-11T15:11:33.672+08:00 INFO 48096 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2025-04-11T15:11:34.195+08:00 INFO 48096 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@4aaecabd 2025-04-11T15:11:34.196+08:00 INFO 48096 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2025-04-11T15:11:34.324+08:00 INFO 48096 --- [ main] org.flywaydb.core.FlywayExecutor : Database: jdbc:postgresql://127.0.0.1:5432/postgres (PostgreSQL 17.4) 2025-04-11T15:11:34.568+08:00 WARN 48096 --- [ main] o.f.c.internal.database.base.Database : Flyway upgrade recommended: PostgreSQL 17.4 is newer than this version of Flyway and support has not been tested. The latest supported version of PostgreSQL is 16. 2025-04-11T15:11:34.719+08:00 INFO 48096 --- [ main] o.f.c.i.s.JdbcTableSchemaHistory : Schema history table "mydb"."flyway_schema_history" does not exist yet 2025-04-11T15:11:34.768+08:00 INFO 48096 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 1 migration (execution time 00:00.149s) 2025-04-11T15:11:35.201+08:00 INFO 48096 --- [ main] o.f.c.i.s.JdbcTableSchemaHistory : Creating Schema History table "mydb"."flyway_schema_history" ... 2025-04-11T15:11:35.920+08:00 INFO 48096 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "mydb": << Empty Schema >> 2025-04-11T15:11:35.967+08:00 INFO 48096 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "mydb" to version "1 - create user table" 2025-04-11T15:11:36.064+08:00 WARN 48096 --- [ main] o.f.c.i.s.DefaultSqlScriptExecutor : DB: schema "mydb" already exists, skipping (SQL State: 42P06 - Error Code: 0) 2025-04-11T15:11:36.802+08:00 INFO 48096 --- [ main] o.f.core.internal.command.DbMigrate : Successfully applied 1 migration to schema "mydb", now at version v1 (execution time 00:00.192s) 2025-04-11T15:11:37.174+08:00 INFO 48096 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
添加 V2__add_user_status_and_phone.sql,文件内容及启动日志如下:
1 2 3 4 5 6 7 8 9 10 11
-- 添加状态字段 ALTERTABLE mydb.user ADDCOLUMN IF NOTEXISTS status VARCHAR(20) NOTNULLDEFAULT'ACTIVE';
-- 添加手机号字段 ALTERTABLE mydb.user ADDCOLUMN IF NOTEXISTS phone VARCHAR(20);
-- 添加手机号唯一索引 CREATEUNIQUE INDEX IF NOTEXISTS idx_user_phone ON mydb.user(phone) WHERE phone ISNOTNULL;
-- 添加状态索引 CREATE INDEX IF NOTEXISTS idx_user_status ON mydb.user(status);
1 2 3 4 5 6 7 8 9 10
2025-04-11T15:14:01.238+08:00 INFO 48561 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2025-04-11T15:14:01.760+08:00 INFO 48561 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@2407a36c 2025-04-11T15:14:01.761+08:00 INFO 48561 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2025-04-11T15:14:01.888+08:00 INFO 48561 --- [ main] org.flywaydb.core.FlywayExecutor : Database: jdbc:postgresql://127.0.0.1:5432/postgres (PostgreSQL 17.4) 2025-04-11T15:14:02.133+08:00 WARN 48561 --- [ main] o.f.c.internal.database.base.Database : Flyway upgrade recommended: PostgreSQL 17.4 is newer than this version of Flyway and support has not been tested. The latest supported version of PostgreSQL is 16. 2025-04-11T15:14:02.402+08:00 INFO 48561 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 2 migrations (execution time 00:00.215s) 2025-04-11T15:14:02.940+08:00 INFO 48561 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "mydb": 1 2025-04-11T15:14:02.996+08:00 INFO 48561 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "mydb" to version "2 - add user status and phone" 2025-04-11T15:14:03.903+08:00 INFO 48561 --- [ main] o.f.core.internal.command.DbMigrate : Successfully applied 1 migration to schema "mydb", now at version v2 (execution time 00:00.293s) 2025-04-11T15:14:04.246+08:00 INFO 48561 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'