Giter VIP home page Giter VIP logo

php-mysql-migrate's Introduction

php-sql-migrate

Tiny one file migration script for MySQL and PostgreSQL using PHP, built for the minimalist.

Handles migrating your database schema upwards. Easy to use in different environments: multiple developers, staging, production. Just run migrate and it will move the database schema to the latest version. Will detect conficts and print out errors.

How to use

If you already have a GIT repo for your server, then:

git submodule add https://github.com/kennberg/php-mysql-migrate php-sql-migrate
git submodule init

Or, for installation inside your server directory:

git clone https://github.com/kennberg/php-sql-migrate

To add a new migration:

php php-sql-migrate/migrate.php add [name-without-spaces]

To migrate to the latest version:

php php-sql-migrate/migrate.php migrate

The migrate script will create a ".version" file in the directory from which it is run. For this reason, I recommend running the migration script from one level up. Do not checkin the version file since it needs to be local!

When you add a new migration, a new script file will be created under the "migrations/" folder and this folder should be checked into the code repository. This way other enviornments can migrate the database using them.

More info

To setup your database information, make sure to run:

cp config.php.sample config.php
vim config.php

The database version is tracked locally using file ".version".

The MySQL database link is available using "$link" variable.

Make sure that you use the function "query" instead of "mysql_query" in the migration scripts, since it handles error reporting.

License

Apache v2. See the LICENSE file.

php-mysql-migrate's People

Contributors

kennberg avatar rocknroyal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.