Download the PHP package ngyuki/dbdatool without Composer

On this page you can find all versions of the php package ngyuki/dbdatool. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dbdatool

dbdatool

Build Status Latest Stable Version Latest Unstable Version License

database diff/apply tool.

稼働集のデータベースからスキーマ定義ファイルをダンプし、その定義と別のデータベースを比較して差分を ALTER TABLE などの SQL の形で表示したり、差分をデータベースへ適用したりするマイグレーションツールです。

dbdatool dump > schema.json でデータベースからスキーマ定義ファイルを出力します。dbdatool apply schema.jsonschema.json に書かれたスキーマ定義とデータベースを比較して差分を ALTER TABLE などで適用します。

Demo

Install

You can download phar file, see https://github.com/ngyuki/dbdatool/releases

簡単な使い方

config.php にデータベース接続情報を記述します。

composer.json にコンフィグのパスを追記します。

データベースからスキーマ定義ファイルを出力します。

スキーマ定義ファイルとデータベースを比較して差分を表示します。

差分をデータベースに適用します。

dbdatool dump

動いているデータベースからスキーマ定義ファイルをダンプします。

source にはダンプ元のデータソースを指定します。省略すれば @ で、これはコンフィグで指定されたデータベースです。

dbdatool diff

2 つのデータソースを比較して、差分を ALTER TABLE などの SQL で表示します。

target を source に一致させるための差分が表示されます。例えば target のみにテーブルが存在すれば DROP TABLE されます(直感の逆になっているかも)。

target は省略可能です。省略すれば @ で、これはコンフィグで指定されたデータベースです。つまりデータソースをひとつだけ指定した場合は「コンフィグのデータベースを、指定したデータソースのスキーマ定義に一致させるための DDL」が表示されます。

dbdatool apply

2 つのデータソースを比較して、差分を実際にデータベースへ適用します。

source の定義を target に差分で反映させます。

target は省略可能です。省略すれば @ で、これはコンフィグで指定されたデータベースです。つまりデータソースをひとつだけ指定した場合は「指定したデータソースのスキーマ定義を、コンフィグのデータベース反映」します。

コンフィグファイルの指定

コンフィグファイルは -c|--config オプションで指定するか、オプションで指定しない場合は変わりに composer.json で次のように指定できます。

この場合 dbdatool.php があればそれを、なければ dbdmtool.php.dist が使用されます。

データソースの指定

コマンドで指定するデータソース(データベースやスキーマ定義ファイル)は、下記のいずれかの形式で指定できます。

例えば次のように指定します。

一部のコマンドでは指定できるデータソースに制限があります。例えば apply コマンドの2番目のデータソース(target)には実際のデータベース接続を伴うデータソースを指定する必要があるため、スキーマ定義ファイルや空のデータソースを指定することはできません。

よくある使い方

データベースのスキーマは生の SQL の CREATE TABLE などの DDL で管理しており init.sql にテーブル・インデックス・外部キー制約を作るための SQL が保存されています。

config.php は次のように環境変数を元にデータベース接続情報を返します。

composer.json でコンフィグのファイルパスを指定します。

開発中にスキーマ定義に変更があるときは最初に init.sql を修正します。

init.sql を適当なデータベースにインポートします。

スキーマ定義ファイルをダンプします。

実際のデータベースとの差分を確認して適用します。

Git リポジトリに追加・コミット・プッシュします。

他の開発者は git pull の後にスキーマ定義の変更を適用できます。

制限

スキーマ定義の比較は非常に雑に行っています。

例えば MySQL では booleantinyint のエイリアスですが、スキーマ定義に boolean と記述すると実際のデータベースとの比較で tinyint とは異なるため差分が検出されます。boolean の差分を適用したとしても実際のデータベースでは tinyint なので、スキーマ定義に boolean が書かれていると何度 apply しても差分が出続けます。

このような自体を避けるためにスキーマ定義ファイルは手書きせず dump で稼働中のデータベースから出力することをオススメします。

類似のツール


All versions of dbdatool with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0.10
ext-pdo Version *
ext-json Version *
symfony/console Version ^3.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ngyuki/dbdatool contains the following files

Loading the files please wait ....