tworzenieweb/sql-provisioner
Composer 安装命令:
composer require tworzenieweb/sql-provisioner
包简介
Simple CLI tool for validating SQL files before inserting them into DB.
README 文档
README
SQL Provisioner
Simple CLI tool for database changes deploying. It allows to review each dbdeploy file before executution.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Prerequisites
To use this library, you would need to have composer installed and have a table for storing already performed DB deploys.
Lastly, you would need to provide .env file with connection information and table and column name for checks
DATABASE_USER=[user]
DATABASE_PASSWORD=[password]
DATABASE_HOST=[host]
DATABASE_PORT=[port]
DATABASE_NAME=[database]
PROVISIONING_TABLE=changelog_database_deployments
PROVISIONING_TABLE_CANDIDATE_NUMBER_COLUMN=deploy_script_number
Installing
It installs just like any other composer project
composer require tworzenieweb/sql-provisioner
Then you should be able to run command from vendor/bin/sql-provisioner
vendor/bin/sql-provisioner /location/to/your/sql/files
Using
The vendor/bin/sql-provisioner [path-to-folder] command will scan the content of [path-to-folder] directory.
The script will look for .env file containing connection information in format:
DATABASE_USER=[user]
DATABASE_PASSWORD=[password]
DATABASE_HOST=[host]
DATABASE_PORT=[port]
DATABASE_NAME=[database]
PROVISIONING_TABLE=changelog_database_deployments
PROVISIONING_TABLE_CANDIDATE_NUMBER_COLUMN=deploy_script_number
If you want to create initial .env use --init
vendor/bin/sql-provisioner --init [path-to-folder]
The next step is searching for sql files and trying to queue them in numerical order. First n-th digits of a filename will be treated as candidate number. This will be used then to check in database if a certain file was already deployed (PROVISIONING_TABLE_CANDIDATE_NUMBER_COLUMN). Before the insert, it will print the formatted output of a file and result of internal syntax check. Then you can either skip or execute each.
If you would like to skip already provisioned candidates use --skip-provisioned
If you would like to skip syntax checking (for speed purpose) of candidates use --skip-syntax-check
Demo
This is cinerama demo of usage
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Luke Adamczewski - Initial work - tworzenieweb
License
This project is licensed under the MIT License - see the LICENSE.md file for details
统计信息
- 总下载量: 93
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-03