Code Monkey home page Code Monkey logo

sql-provisioner's Introduction

Build Status Scrutinizer Code Quality

SensioLabsInsight

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

asciicast

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

sql-provisioner's People

Contributors

tworzenieweb avatar scrutinizer-auto-fixer avatar ed-posinitskiy avatar stevleibelt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.