私はこの男のページに従って、Liquibase のセットアップ ( http://bytefilia.com/managing-database-schema-changes-liquibase-existing-schema/ ) を取得し、少なくとも私のベース テーブルとデータを使用しています。無事に完走しました
./liquibase --driver=com.mysql.jdbc.Driver \
--classpath=lib/mysql-connector-java-5.1.34-bin.jar \
--changeLogFile="../data/database/boot.json" \
--url="jdbc:mysql://localhost/tester" \
--username=root \
--password=password \
--logLevel=debug \
generateChangeLog
これをテーブル構造用とデータ用に 2 回行います。
./liquibase --driver=com.mysql.jdbc.Driver \
--classpath=lib/mysql-connector-java-5.1.34-bin.jar \
--changeLogFile="../data/database/base-data.json" \
--url="jdbc:mysql://localhost/tester" \
--username=root \
--password=password \
--logLevel=debug \
--diffTypes="data"
generateChangeLog
boot.json と base-data.json の両方のファイルが生成されます。これらのファイルは、少なくとも他の Web サイトや liquibase ファイルと比較して優れているようです。私が見つけた唯一の問題は、データファイルで日時スタンプが ":" に関するエラーを生成することですが、それらを引用符で囲むと、liquibase が実行され、syas が正常に実行されました。データベースを確認したところ、テーブルが2つしかありませんでした。
DATABASECHANGELOG
DATABASECHANGELOGLOCK
DATABASECHANGELOG の中を見ると、sync コマンドを実行した後、両方のファイルからのすべてのコミットが含まれています。しかし、必要なテーブルはなく、もちろんデータもありません。バージョン管理されているテーブルが表示されないのではないかと思ったので、通常のselectステートメントを試しました。
select * from ua_auth_user;
ERROR 1146 (42S02): Table 'tester.ua_auth_user' doesn't exist
どんな助けも素晴らしいです。エクスポートしたデータを使用して、新しいデータベースからスキーマを生成する liquibase を取得するには、どうすればよいですか。データとテーブル構造を取得する際に何か間違ったことをした場合は、それを変更します。私は、主要な開発を試みる前に、実際の例を実行するための指示に従っていただけでした。
---更新 (Nathan Voxland からの次の提案)
最初に 1 つのテーブルを除いてすべてのテーブルを削除しました。データベースを削除して、新しいデータベースを作成しました。次に、以下のコマンドを実行しました。
boot.json
{ "databaseChangeLog": [
{
"changeSet": {
"id": "1",
"author": "lumberjacked",
"changes": [
{
"createTable": {
"columns": [
{
"column": {
"autoIncrement": true,
"constraints": {
"constraints": {
"primaryKey": true
}
},
"name": "id",
"type": "INT"
}
},
{
"column": {
"name": "subject_category_id",
"type": "INT"
}
},
{
"column": {
"name": "subject",
"type": "VARCHAR(50)"
}
},
{
"column": {
"name": "label",
"type": "VARCHAR(50)"
}
}]
,
"tableName": "common__subjects"
}
}]
}
}
]}
指示
➜ liquibase-bin git:(test) ✗ ./liquibase
--driver=com.mysql.jdbc.Driver
--classpath=lib/mysql-connector-java-5.1.34-bin.jar
--changeLogFile="../data/database/boot.json"
--url="jdbc:mysql://localhost/tester"
--username=root
--password=password
--logLevel=debug update
エラーメッセージ
Unexpected error running Liquibase:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect
table definition; there can be only one auto column and it must be
defined as a key
SEVERE 1/18/15 4:05 PM: liquibase:
../data/database/boot.json::1::lumberjacked:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect
table definition; there can be only one auto column and it must be
defined as a key