All Projects → alwex → php-database-migration

alwex / php-database-migration

Licence: other
Database Migration tool for PHP

Programming Languages

PHP
23972 projects - #3 most used programming language
Smarty
1635 projects

Projects that are alternatives of or similar to php-database-migration

Scala Forklift
Type-safe data migration tool for Slick, Git and beyond.
Stars: ✭ 180 (+109.3%)
Mutual labels:  database-migrations
flyway-ant
Flyway Ant tasks
Stars: ✭ 14 (-83.72%)
Mutual labels:  database-migrations
harmonica
Kotlin Database Migration Tool. This tool makes it really easy to create table, index, add columns, and so on, with Kotlin DSL.
Stars: ✭ 123 (+43.02%)
Mutual labels:  database-migrations
Liquibase
Main Liquibase Source
Stars: ✭ 2,910 (+3283.72%)
Mutual labels:  database-migrations
migrate
A simple database migration tool.
Stars: ✭ 38 (-55.81%)
Mutual labels:  database-migrations
sqflite migration
Library to manage sqlite db migrations.
Stars: ✭ 40 (-53.49%)
Mutual labels:  database-migrations
Postgres Migrations
🐦 A Stack Overflow-inspired PostgreSQL migration library with strict ordering and immutable migrations
Stars: ✭ 161 (+87.21%)
Mutual labels:  database-migrations
java-migrations
📃 Laravel inspired DBS-independent Database Migrations for Java 8 (work in progress)
Stars: ✭ 21 (-75.58%)
Mutual labels:  database-migrations
migrations
Migrations is a database migration tool that uses go's database/sql from the standard library
Stars: ✭ 17 (-80.23%)
Mutual labels:  database-migrations
neo4j-migrations
Automated script runner aka "Migrations" for Neo4j. Inspired by Flyway.
Stars: ✭ 82 (-4.65%)
Mutual labels:  database-migrations
Aerich
A database migrations tool for TortoiseORM, ready to production.
Stars: ✭ 240 (+179.07%)
Mutual labels:  database-migrations
r2dbc-migrate
R2DBC database migration tool & library
Stars: ✭ 83 (-3.49%)
Mutual labels:  database-migrations
DBTestCompare
Application to compare results of two SQL queries
Stars: ✭ 15 (-82.56%)
Mutual labels:  database-migrations
Obevo
Obevo is a database deployment tool that handles enterprise scale schemas and complexity
Stars: ✭ 192 (+123.26%)
Mutual labels:  database-migrations
Sane
"Spring Boot for Classic ASP." A powerful and full-featured VBScript MVC framework that brings sanity to Classic ASP development. Use domain & view models, automap model -> view, easily enumerate and introspect, write db migrations, and more. No, seriously.
Stars: ✭ 26 (-69.77%)
Mutual labels:  database-migrations
Phinx Migrations Generator
A Migration Code Generator for Phinx
Stars: ✭ 178 (+106.98%)
Mutual labels:  database-migrations
migrant
Migration management for PostgreSQL/SQLite/MySQL
Stars: ✭ 85 (-1.16%)
Mutual labels:  database-migrations
wildebeest
Database migration for Sequelize.
Stars: ✭ 13 (-84.88%)
Mutual labels:  database-migrations
db-migrator.go
DB migrations. CLI and Golang
Stars: ✭ 13 (-84.88%)
Mutual labels:  database-migrations
upscheme
Database migrations and schema updates made easy
Stars: ✭ 737 (+756.98%)
Mutual labels:  database-migrations

PhpDbMigration - full PHP database migration tool

Build Status Packagist Version

SensioLabsInsight

This is a full standalone PHP tool based on Symfony Console and inspired by the Rails database migration tool and MyBatis. It merges the functionality of the two tools and has been designed to be as flexible as possible.

Usage

$ ./bin/migrate
Console Tool

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help            Displays help for a command
  list            Lists commands
 migrate
  migrate:addenv  Initialise an environment to work with php db migrate
  migrate:create  Create a SQL migration
  migrate:down    Rollback all waiting migration down to [to] option if precised
  migrate:init    Create the changelog table on your environment database
  migrate:status  Display the current status of the specified environment
  migrate:up      Execute all waiting migration up to [to] option if precised

Installing it to your project

Just add it to your composer.json (don't forget to specify your bin directory) Warning, all migrate commands must be executed on your root folder like bin/migrate migrate:command...

{
    "name": "jdoe/testproject",
    "authors": [
        {
            "name": "Jhon DOE",
            "email": "[email protected]"
        }
    ],
    "require": {
        "php-database-migration/php-database-migration" :"3.6.*"
    },
    "config": {
        "bin-dir": "bin"
    }
}

Adding an environment

The first thing to do before playing with SQL migrations is to add an environment, let's add the dev one.

$ ./bin/migrate migrate:addenv

You will be prompted to answer a series of questions about your environment, and then a config file will be saved in ./.php-database-migration/environments/[env].yml.

Initialization

Once the environment is added, you have to initialize it. This verifies that the database connection works, and creates a new database table for tracking the current database changes:

$ ./bin/migrate migrate:init [env]

Create a migration

It is time to create our first migration file.

$ ./bin/migrate migrate:create

Migrations file are like this

-- // add table users
-- Migration SQL that makes the change goes here.
create table users (id integer, name text);
-- @UNDO
-- SQL to undo the change goes here.
drop table users;

List migrations

View all available migrations and their status.

$ ./bin/migrate migrate:status [env]
+----------------+---------+------------------+--------------------+
| id             | version | applied at       | description        |
+----------------+---------+------------------+--------------------+
| 14679010838251 |         |                  | create table users |
+----------------+---------+------------------+--------------------+

Up and down

You can now up all the pending migrations. If you decide to down a migration, the last one will be downed alone to prevent mistakes. You will be asked to confirm the downgrade of your database before running the real SQL script.

$ ./bin/migrate migrate:up [env]

You can mark migrations as applied without executing SQL (e.g. if you switched from another migration system)

$ ./bin/migrate migrate:up [env] --changelog-only

For development purposes, it is also possible to up a single migration without taking care of the other ones:

$ ./bin/migrate migrate:up [env] --only=[migrationid]

or migrate to specific migration (it will run all migrations, including the specified migration)

$ ./bin/migrate migrate:up [env] --to=[migrationid]

Same thing for down:

$ ./bin/migrate migrate:down [env] --only=[migrationid]

or

$ ./bin/migrate migrate:down [env] --to=[migrationid]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].