Coder Social home page Coder Social logo

trafficinc / pm-migrate Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 19 KB

PM Migrate is a simple upward migration library so you can write your migrations in SQL. Use with ANY PHP framework or no-framework.

PHP 100.00%
migration migrations database-migrations database-migration mysql-migration mysql-migrations

pm-migrate's Introduction

PM MIGRATE

PM Migrate is an easy to use PHP/MySQL migrations library for those who want to keep their migrations in SQL in a minimal way, it handles upward migrations.

How to Use

1.) Git Clone or Download this project into your project root. (Or same level as artisan in Laravel)

2.) Edit the example.config, fill in your config values and save the file as .config

3.) Add new migration: php pm-migrate/migrate.php migrate:add [migration-name-without-spaces]

4.) Open/Edit the migration file [migrations/migrate-000x-name.php] with needed migration SQL code.

5.) To migrate to the latest version: php pm-migrate/migrate.php migrate

Running migrate will create a .version file that will track your migration versions. You can also go to the help menu php pm-migrate/migrate.php help for more options.

New migrations, when "added" will appear under the /migrations folder. You can then add as much SQL code as needed like so:

<?php

use App\Config\Config;
use App\Commands\Migrate;


$query = "ALTER TABLE roles ADD COLUMN role_name VARCHAR(15) AFTER type;";

(new Migrate(new Config()))->query($query);

OR

<?php

use App\Config\Config;
use App\Commands\Migrate;


$query1 = "ALTER TABLE roles ADD COLUMN role_name VARCHAR(15) AFTER type;";

(new Migrate(new Config()))->query($query1);

$query2 = "ALTER TABLE users ADD COLUMN user_name VARCHAR(150) AFTER email;";

(new Migrate(new Config()))->query($query2);

$query2 = "ALTER TABLE users ADD COLUMN password VARCHAR(15) AFTER user_name;";

(new Migrate(new Config()))->query($query2);

OR

<?php

use App\Config\Config;
use App\Commands\Migrate;

$migrate = new Migrate(new Config());

$query1 = "ALTER TABLE roles ADD COLUMN role_name VARCHAR(15) AFTER type;";

$migrate->query($query1);

$query2 = "ALTER TABLE users ADD COLUMN user_name VARCHAR(150) AFTER email;";

$migrate->query($query2);

$query2 = "ALTER TABLE users ADD COLUMN password VARCHAR(15) AFTER user_name;";

$migrate->query($query2);

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.