--liquibase formatted sql
--changeset CASE-0-1:1 failOnError:true
CREATE TABLE tt1(
cc1 INT(11));
--rollback DROP TABLE tt1;
--rollback CREATE TABLE tr1(
--rollback cr1 INT(20));
--liquibase formatted sql
--changeset CASE-0-2:1 failOnError:true
CREATE TABLE tt2(
cc2 INT(11));
--rollback DROP TABLE tt2;
--rollback CREATE TABLE tr2(
--rollback cr2 INT(20));
case-0-3.sql:
--liquibase formatted sql
--changeset CASE-0-3:1 failOnError:true
CREATE TABLE tt3(
cc3 INT(11));
--rollback DROP TABLE tt3;
--rollback CREATE TABLE tr3(
--rollback cr3 INT(20));
I在进行任何更改之前标记数据库:
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--logFile=0state.tag.log --username=trunk --password=Trunk \
tag "0state"
之后,我应用文件,并在每个文件应用后标记数据库:
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--changeLogFile=CASE-0-1.sql --logFile=CASE-0-1.sql.update.log --username=trunk --password=Trunk \
update
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--logFile=CASE-0-1.sql.tag.log --username=trunk --password=Trunk \
tag "CASE-0-1"
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--changeLogFile=CASE-0-2.sql --logFile=CASE-0-2.sql.update.log --username=trunk --password=Trunk \
update
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--logFile=CASE-0-2.sql.tag.log --username=trunk --password=Trunk \
tag "CASE-0-2"
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--changeLogFile=CASE-0-3.sql --logFile=CASE-0-3.sql.update.log --username=trunk --password=Trunk \
update
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--logFile=CASE-0-3.sql.tag.log --username=trunk --password=Trunk \
tag "CASE-0-3"
[root@mysql]# mysql -e "SELECT ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, EXECTYPE, DESCRIPTION, COMMENTS, TAG \
> FROM DATABASECHANGELOG;" liquibase_test
+---------------+-----------+--------------------+---------------------+---------------+----------+-------------+----------+----------+
| ID | AUTHOR | FILENAME | DATEEXECUTED | ORDEREXECUTED | EXECTYPE | DESCRIPTION | COMMENTS | TAG |
+---------------+-----------+--------------------+---------------------+---------------+----------+-------------+----------+----------+
| 1506498093527 | liquibase | liquibase-internal | 2017-09-27 10:41:33 | 1 | EXECUTED | empty | | 0state |
| 1 | CASE-0-1 | CASE-0-1.sql | 2017-09-27 10:41:57 | 2 | EXECUTED | sql | | CASE-0-1 |
| 1 | CASE-0-2 | CASE-0-2.sql | 2017-09-27 10:42:08 | 3 | EXECUTED | sql | | CASE-0-2 |
| 1 | CASE-0-3 | CASE-0-3.sql | 2017-09-27 10:42:12 | 4 | EXECUTED | sql | | CASE-0-3 |
+---------------+-----------+--------------------+---------------------+---------------+----------+-------------+----------+----------+
[root@mysql]# mysql -e "SHOW TABLES;" liquibase_test
+--------------------------+
| Tables_in_liquibase_test |
+--------------------------+
| DATABASECHANGELOG |
| DATABASECHANGELOGLOCK |
| tt1 |
| tt2 |
| tt3 |
+--------------------------+
/root/liquibase/liquibase --logLevel=debug --classpath=/usr/share/java/mysql-connector-java.jar --driver=com.mysql.jdbc.Driver \
--url="jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true" \
--changeLogFile=CASE-0-2.sql --logFile=CASE-0-2.sql.rollback.log --username=trunk --password=Trunk \
rollback "CASE-0-2"
Liquibase Rollback Successful
[root@mysql]# mysql -e "SELECT ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, EXECTYPE, DESCRIPTION, COMMENTS, TAG \
> FROM DATABASECHANGELOG;" liquibase_test
+---------------+-----------+--------------------+---------------------+---------------+----------+-------------+----------+----------+
| ID | AUTHOR | FILENAME | DATEEXECUTED | ORDEREXECUTED | EXECTYPE | DESCRIPTION | COMMENTS | TAG |
+---------------+-----------+--------------------+---------------------+---------------+----------+-------------+----------+----------+
| 1506498093527 | liquibase | liquibase-internal | 2017-09-27 10:41:33 | 1 | EXECUTED | empty | | 0state |
| 1 | CASE-0-1 | CASE-0-1.sql | 2017-09-27 10:41:57 | 2 | EXECUTED | sql | | CASE-0-1 |
| 1 | CASE-0-2 | CASE-0-2.sql | 2017-09-27 10:42:08 | 3 | EXECUTED | sql | | CASE-0-2 |
| 1 | CASE-0-3 | CASE-0-3.sql | 2017-09-27 10:42:12 | 4 | EXECUTED | sql | | CASE-0-3 |
+---------------+-----------+--------------------+---------------------+---------------+----------+-------------+----------+----------+
[root@mysql]# mysql -e "SHOW TABLES;" liquibase_test
+--------------------------+
| Tables_in_liquibase_test |
+--------------------------+
| DATABASECHANGELOG |
| DATABASECHANGELOGLOCK |
| tt1 |
| tt2 |
| tt3 |
+--------------------------+
[root@mysql]# cat CASE-0-2.sql.rollback.log:
DEBUG 27.09.17 10:53: liquibase: Connected to trunk2@127.0.0.1@jdbc:mysql://localhost/liquibase_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true
DEBUG 27.09.17 10:53: liquibase: Setting auto commit to false from true
DEBUG 27.09.17 10:53: liquibase: Executing QUERY database command: select count(*) from liquibase_test.DATABASECHANGELOGLOCK
DEBUG 27.09.17 10:53: liquibase: Executing QUERY database command: select count(*) from liquibase_test.DATABASECHANGELOGLOCK
DEBUG 27.09.17 10:53: liquibase: Executing QUERY database command: SELECT LOCKED FROM liquibase_test.DATABASECHANGELOGLOCK WHERE ID=1
DEBUG 27.09.17 10:53: liquibase: Lock Database
DEBUG 27.09.17 10:53: liquibase: Executing UPDATE database command: UPDATE liquibase_test.DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'mysql-gigantic-dummy-dvaco-trunk-28.aws.srv (172.29.13.83)', LOCKGRANTED = '2017-09-27 10:53:26.625' WHERE ID = 1 AND LOCKED = 0
INFO 27.09.17 10:53: liquibase: Successfully acquired change log lock
DEBUG 27.09.17 10:53: liquibase: Computed checksum for 1506498806750 as 17f1742877fc068db5453ca9db9d60e3
DEBUG 27.09.17 10:53: liquibase: Executing QUERY database command: SELECT MD5SUM FROM liquibase_test.DATABASECHANGELOG WHERE MD5SUM IS NOT NULL LIMIT 1
DEBUG 27.09.17 10:53: liquibase: Executing QUERY database command: select count(*) from liquibase_test.DATABASECHANGELOG
INFO 27.09.17 10:53: liquibase: Reading from liquibase_test.DATABASECHANGELOG
DEBUG 27.09.17 10:53: liquibase: Executing QUERY database command: SELECT * FROM liquibase_test.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
DEBUG 27.09.17 10:53: liquibase: CASE-0-2.sql: CASE-0-2.sql::1::CASE-0-2: Computed checksum for inputStream as 80fa2b893f3b36ef72cf796a9ce61189
DEBUG 27.09.17 10:53: liquibase: CASE-0-2.sql: CASE-0-2.sql::1::CASE-0-2: Computed checksum for 7:80fa2b893f3b36ef72cf796a9ce61189: as 6c11f0a414ae9865f42a220f71f1e3d1
DEBUG 27.09.17 10:53: liquibase: Release Database Lock
DEBUG 27.09.17 10:53: liquibase: Executing UPDATE database command: UPDATE liquibase_test.DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 27.09.17 10:53: liquibase: Successfully released change log lock
希望您仍然对帮助感兴趣,但据我所知,您不包括您的CASE-0-2 SQL脚本,因此liquibase不知道在您提供的CASE-0-2标记之外应用的更改,因此它无法回滚。
我的团队所做的是创建一个更健壮的changelog.xml
来引用我们的.sql脚本,而不是使用.sql脚本作为changelog文件。
如果有帮助就告诉我!
case-0-3.sql: 我在进行任何更改之前标记数据库: 之后,我在每个文件应用后应用文件和标记数据库: 求求你,救命。可能有人在sql或其他格式中使用回滚操作?哪里错了?我做错了什么?它是工作液基功能吗?
我的问题是liquibase没有回滚我的一些变更集,这些变更集是在我试图回滚的变更集上设置标签后执行的。 例如,我创建了两个按正常方式执行的变更集(A和B)。然后,我创建了另一个变更集,它将变更集B的标记设置为Release1。并且这个变更集也按预期工作。但是,我随后执行另外5个变更集,所有变更集都使用回滚命令。而且这些也执行得很好。 现在,这个回滚不应该回滚在执行release1标记之后执行的任
我正在处理一个分支,例如需要删除表X中的一列,我添加了一个更改,它对该特定分支有好处,然后我切换到另一个分支,该分支仍然需要该列,并且该更改需要回滚。db在不同的分支之间有很多变化,比如这样的变化。 我为每个分支添加一个新的changelog xml,并将其包含在主changelog xml中。显然,当我切换到另一个分支时,前一个分支的changlog xml不再在工作区中,并且liquibase
我是一名实习生,我正在尝试学习Liquibase,看看我们是否可以将其用于我们的应用程序。我使用了Git Bash中的Liquibase,没有任何问题(在更新和回滚方面都很好),然后我尝试将Liquibase与Spring Boot项目一起使用,看看是否能够更新数据库。我做到了,我通过Spring Boot创建并更新了db。但接下来我想做一些回滚,但我不能,我不知道该做什么。我试着在Git Bas
Liquibase在Java世界中类似于EntityFramework(EF)。并且=在中。但问题是只生成,但没有回滚。有可能在回滚的同时生成差异吗? 我试着用liquibase:rollback创建回滚脚本。但它并不能在所有情况下都生成回滚脚本,例如,当我删除了一个带有更改集的列,然后想要回滚时。设置或运行时出错
我有一个简单的liquibase变更集(下面),我正在尝试测试它。 这是应用程序启动后运行的第二个更改日志。 我故意编写了一个错误代码,其中我尝试创建列“new_2”两次,以强制回滚变更集中的所有条目:ADD_COL_2 然而,即使生成了回滚文件,并且我看到: 信息4/13/16 12:17 AM:LiquiBase:classpath:db/changelog/db.changelog-mult