2017 © Pedro Peláez
 

library php-migrations

image

torandi/php-migrations

  • Saturday, April 15, 2017
  • by Torandi
  • Repository
  • 1 Watchers
  • 4 Stars
  • 173 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

Introduction

This is a php-script that helps you handling versions of your database in a format that works well with code versioning., (*1)

Configuration and setup

  1. composer require torandi/php-migrations
  2. Create a directory in your project named "migrations" (or whatever)
  3. Symlink update_database.php and create_migration.php into the directory.
  4. Copy config-example.php to config.php and edit it to fit your project (see config-example.php for more info)

Usage

Use ./create_migration.php migration_name to create a new migration, (*2)

This creates a empty migration with a name like 20110821231945_migration_name.sql. The file name (including the date) is the version name, and must be unique., (*3)

You may also specify a second argument to create_migration to select file format (sql or php): * SQL: SQL to be run for the migration (multiple lines separated by ;) * PHP: PHP code to be executed, the environment you loaded in config.php is available, remember <?php and be verbose. Not run in global scope, (*4)

To then run the migrations execute ./update_database.php which runs all unrun migrations. The table schema_migrations are created (if not exist) containing all run migrations., (*5)

PHP-migration-script-helper-functions

migration_sql(query): Print and run query run_sql(query): Run query in silence, (*6)

update_database.php usage

./update_database.php [options] [username], (*7)

Username may be optional, depending on your config.php, (*8)

Arguments

--help,  -h: Show help
--check, -c: Checks if there are any migrations to run, but does not run them (dry run)

The Versions

15/04 2017

dev-master

9999999-dev

  Sources   Download

by Andreas Tarandi

15/02 2016

v1.0

1.0.0.0

  Sources   Download

by Andreas Tarandi