2017 © Pedro Peláez
 

library rake-db-migrator

Rails migration for php projects

image

rajibahmed/rake-db-migrator

Rails migration for php projects

  • Friday, January 10, 2014
  • by rajibahmed
  • Repository
  • 3 Watchers
  • 8 Stars
  • 8 Installations
  • Ruby
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Rails Less Migration

Today I was wanted to use rails goodness inside of my php project. So, I searched online found a solution somewhere. Fixed it up for any project to use using composer., (*1)

I assume you are using tools listed below and know how to use command line., (*2)

  • POSIX OS
  • Ruby the programming Language
  • Rake the build tool written in Ruby
  • Activerecord gem, defaults with Rails !!!!

To enable it, add this dependency to your composer.json file:, (*3)

"rajibahmed/rake-db-migrator": "dev"

Step 1: To enable it in your application you need to create few directories from you terminal :), (*4)

$ mkdir -p db/migrate
$ mkdir config

Note 1: You do not need to create the structure if you already have it. Note 2: I have provided a demo database.yml configuration file copy over to config folder. Important: If you don't have valid database.yml this generator will not work., (*5)

Step 2: symlink my rake file to root of you project., (*6)

$ ln -s vendor/rajibahmed/rake-db-migrator/Rakefile .

Step 3: You are done !!, (*7)

Usage

So now you can use this rake file to create and migrate you configured database. Available Rake tasks are,, (*8)

 rake db:create    # Create the database from config/database.yml for the current DATABASE_ENV
 rake db:drop      # Drops the database for the current DATABASE_ENV
 rake db:generate  # Generate migration files
 rake db:migrate   # Migrate the database (options: VERSION=x, VERBOSE=false).
 rake db:rollback  # Rolls the schema back to the previous version (specify steps w/ STEP=n).
 rake db:version   # Retrieves the current schema version number

Now, Running, (*9)

rake db:generate

Will create a template file that you can use as a reference point for writing your first migration., (*10)

Note[IMPORTANT] : Class name in a migration file must match the file naming convention. ie., (*11)

Name migration file

Now you can pass in the migration file name. But follow the convention underscore word., (*12)

rake db:generate[create_users]

This will generate code like this., (*13)


# db/migrate/....._create_user.rb CreateUser < ActiveRecord::Migration # file name should be timestramp_create_user.rb end

You are good to go !!! This is a few hours effort. If you want to extend it please fork it or send me emails., (*14)

LICENSE: Do whatever you want with it. I don't want money from you and can't be held responsible any fu*k ups. Good luck !!! Simple isn't it., (*15)

The Versions

10/01 2014

dev-master

9999999-dev

Rails migration for php projects

  Sources   Download

MIT

The Requires

  • php >=5.2

 

by Rajib Ahmed

database migration rails