SchemaSpyでER図とDB設計書を自動生成するSchemaSpyを既存アプリのDockerに導入する でMySQLとPostgreSQLに対して実施しましたが、
SQLite3でも試しみて、少し手こずったので、メモしておきます。

SQLite3向け設定

JDBCドライバー

前回作成したjdbcディレクトリに下記をダウンロードして設置
https://github.com/xerial/sqlite-jdbc/releases
sqlite-jdbc-3.36.0.1.jar

sqlite.propertiesを作成

sqlite.properties

description=SQLite
connectionSpec=jdbc:sqlite:<db>
driver=org.sqlite.JDBC

schemaspy.t=sqliteを指定すると下記エラーになるので、作成したのもで置き換える。

WARN  - Connection Failure
Failed to connect to database URL [jdbc:sqlite:../db/development.sqlite3] 
Failed to create any of 'SQLite.JDBCDriver' driver from driverPath 'jdbc' with sibling jars no.

schemaspy.propertiesを修正

schemaspy.properties

schemaspy.t=sqlite.properties
schemaspy.dp=jdbc
#schemaspy.host=
#schemaspy.port=
schemaspy.s=dumy
schemaspy.db=../db/development.sqlite3
schemaspy.u=dumy
#schemaspy.p=
schemaspy.o=analysis
schemaspy.cat=dumy

u(ユーザー)は何でも良いけど必要

ERROR - The following option is required: [-u | --user | user | schemaspy.u | schemaspy.user]
The following option is required: [-u | --user | user | schemaspy.u | schemaspy.user]

catを追加。何か有れば良さそう

ERROR - Bad config
Catalog (-cat) was not provided and unable to deduce catalog, 
wildcard catalog can be used -cat %

s(スキーマ)も何か有れば良さそう

ERROR - Bad config
Schema (-s/-schemas) was not provided and unable to deduce schema, 
schema is sometimes referred to as user/owner/database

実行

% java -jar schemaspy-6.1.0.jar
  ____       _                          ____
 / ___|  ___| |__   ___ _ __ ___   __ _/ ___| _ __  _   _
 \___ \ / __| '_ \ / _ \ '_ ` _ \ / _` \___ \| '_ \| | | |
  ___) | (__| | | |  __/ | | | | | (_| |___) | |_) | |_| |
 |____/ \___|_| |_|\___|_| |_| |_|\__,_|____/| .__/ \__, |
                                             |_|    |___/

                                              6.1.0

SchemaSpy generates an HTML representation of a database schema's relationships.
SchemaSpy comes with ABSOLUTELY NO WARRANTY.
SchemaSpy is free software and can be redistributed under the conditions of LGPL version 3 or later.
http://www.gnu.org/licenses/

INFO  - Starting Main v6.1.0 on xxxx with PID 43435 (/Users/xxxx/workspace/rails-app-origin/schemaspy/schemaspy-6.1.0.jar started by xxxx in /Users/xxxx/workspace/rails-app-origin/schemaspy)
INFO  - The following profiles are active: default
INFO  - Found configuration file: schemaspy.properties
INFO  - Started Main in 2.416 seconds (JVM running for 3.233)
INFO  - Loaded configuration from schemaspy.properties
INFO  - Starting schema analysis
INFO  - Connected to SQLite - 3.36.0
INFO  - Gathering schema details
Gathering schema details...INFO  - Found PK without index name created index 'admin_users_s_pk' for table 'admin_users'
.INFO  - Found PK without index name created index 'ar_internal_metadata_s_pk' for table 'ar_internal_metadata'
.INFO  - Found PK without index name created index 'versions_s_pk' for table 'versions'
.INFO  - Found PK without index name created index 'tests_s_pk' for table 'tests'
.INFO  - Found PK without index name created index 'schema_migrations_s_pk' for table 'schema_migrations'
.INFO  - Found PK without index name created index 'users_s_pk' for table 'users'
.INFO  - Found PK without index name created index 'infomations_s_pk' for table 'infomations'
.(0sec)
Connecting relationships..........(0sec)
Writing/graphing summary.INFO  - Gathered schema details in 0 seconds
INFO  - Writing/graphing summary
INFO  - Graphviz rendered set to ''
........(5sec)
Writing/diagramming detailsINFO  - Completed summary in 5 seconds
INFO  - Writing/diagramming details
.......(1sec)
Wrote relationship details of 7 tables/views to directory 'analysis' in 7 seconds.
View the results by opening analysis/index.html
INFO  - Wrote table details in 1 seconds
INFO  - Wrote relationship details of 7 tables/views to directory 'analysis' in 7 seconds.
INFO  - View the results by opening analysis/index.html
% open analysis/index.html 

OK。出ました!


今回のコミット内容
※序でにdatabase.ymlの書き換えだけで、MySQL/PostgreSQL/SQLiteを使えるようにしています。
https://dev.azure.com/nightonly/rails-app-origin/_git/rails-app-origin/commit/44c8267330ca6f3e562115a6063bb1925abb51da

SchemaSpyをSQLite3に使ってみる” に対して1件のコメントがあります。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です