Giter Site home page Giter Site logo

stevefrost / codeigniter-migrations Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blendedbychris/codeigniter-migrations

2.0 2.0 0.0 171 KB

A database migration utility for Codeigniter inspired by Ruby on Rails.

Home Page: http://www.cloudmanic.com

codeigniter-migrations's Introduction

Codeigniter-Migrations

Contributors

Based On

Migrations by Mat'as Montes

About

An open source utility for Codeigniter inspired by Ruby on Rails.

The one thing Ruby on Rails has that Codeigniter does not have built in is database migrations. That function to keep track of database changes (versions) and migrate your database to what ever version you need. Migrate up or migrate down. With this library you can now do this.

Install

Copy the files to these locations.

config/migrations.php -> application/config/
libraries/Migrations.php -> application/libraries/
controllers/migrate.php -> application/controllers/

The migration files included in this are just examples. You should install them where ever you point your $config["migrations_path"] to.

Usage

$this->load->library('migrations');
$this->migrations->set_verbose(TRUE); // echo statements or not
$this->migrations->version(id); // migrate the database to a particular version
$this->migrations->latest(); // migrate the database to the latest version
$this->migrations->install(); // install to the latest version.

The migrate.php controller just shows the use of these functions. If you are going to use it. comment out the show_error() in the construct, and put it back in place when you are done.

Examples

Make sure our database is up-to-date

if ( ! $this->migration->latest())
{
	show_error($this->migration->error);
}

Update (or come back to) migration 5

if ( ! $this->migration->version(5))
{
	show_error($this->migration->error);
}

Other Helpful Stuff

Included in this git repo is an example CodeIgniter Hook and a basic application/config/hooks.php to show how to enable it. This hook is one of several ways to have migrations run on every page load. You could also place the code into a MY_Controller.

codeigniter-migrations's People

Contributors

blendedbychris avatar cloudmanic avatar ericlbarnes avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.