2017 © Pedro Peláez
 

library lib-migration

bytepark Component - Lightweight and flexible database schema and data migration toolkit

image

bytepark/lib-migration

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  • Tuesday, March 22, 2016
  • by bytepark
  • Repository
  • 16 Watchers
  • 1 Stars
  • 432 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

Database migration library

Status

![alt text][2], (*1)

Lightweight database migration library., (*2)

The lib-migration component offers an easy to use API for database migrations controlled from within a project or application, not differentiating between structural or data migrations. The migration workload itself is pure SQL and is currently not verified by the library. The correct syntax and integrity checks are the responsibility of the user., (*3)

TODOS / Open Features

  • Add a CLI implementation (at best as own component) See https://github.com/bytepark/lib-migration-cli
  • Add SQL Schema abstraction for database repository / connection
  • Add some error messaging/logging facility
  • Rename Repository interface to Location?
  • Rename Manager to something better!!!

Concept

The library defines the public interfaces Connection, Repository and Lock. The instance of the Connection interface provides access to the database that is the subject of change, i.e. the database where one wants to migrate against. Implementations of the following databases are bundled in the component using PDO:, (*4)

  • Sqlite memory database
  • Sqlite file database
  • MySQL database

The instance of the Repository interface represent a location where the single work units are persisted. Therefore two repositories must be specified, one representing the source of all the migrations and one representing the history of all already migrated work units. Implementations of two filesystem, a database and a memory located repository are bundled., (*5)

When you want to persist in the filesystem, you can choose between a flat and a grouped directory structure. The work units are save in one directory in the first case and a two subdirectory deep structure - depending on the unique ID of the work unit - in the latter case., (*6)

As the library is to be used in the context of an application, and as applications are nowadays often parallelized, the Manager depends on a locking mechanism to ensure mutual exclusive execution of the database migrations not already present in the history repository., (*7)

The four instances are injected during construction into the Manager class which delegates the migration process., (*8)

Installation

The recommended way to install lib-migration is through Composer., (*9)

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of lib-migration:, (*10)

composer require bytepark/lib-migration

After installing, you need to require Composer's autoloader:, (*11)

require 'vendor/autoload.php';

Usage

Example Filesystem to DB

The migration process scans a defined directory for files with the (default) file extension .mig. The set of files is then diffed against the already migrated set, which is, in the example, persisted in a database table., (*12)

Migration file requirements

The single migrations should be named in some descending sortable syntax to express weak dependencies. Recommended is the naming of the files including a date, datetime or timestamp prefix, i.e. 19700101-some-text.mig. The migrations will be processed in the given order of the directory scan., (*13)

The content of the specific files is the pure SQL queries to execute against the database., (*14)

Bridging Components

Will soon be linked here. Currently we know that the following bridges will be provided, each depending on this component:, (*15)

The Versions

22/03 2016

dev-master

9999999-dev http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration

22/03 2016

1.0.7

1.0.7.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration

16/01 2015

1.0.6

1.0.6.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration

14/01 2015

1.0.5

1.0.5.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration

15/12 2014

1.0.4

1.0.4.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration

12/12 2014

1.0.3

1.0.3.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration

11/12 2014

1.0.2

1.0.2.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

  • ext-pdo_sqlite *

by bytepark GmbH

database library migration

11/12 2014

1.0.1

1.0.1.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration

11/12 2014

1.0

1.0.0.0 http://www.bytepark.de

bytepark Component - Lightweight and flexible database schema and data migration toolkit

  Sources   Download

MIT

The Development Requires

by bytepark GmbH

database library migration