Skip to content

Commit

Permalink
Migrated library to "rougin/blueprint"
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Sep 17, 2015
1 parent 46dc07c commit a750f5b
Show file tree
Hide file tree
Showing 13 changed files with 776 additions and 573 deletions.
78 changes: 37 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,16 @@ $ php vendor/bin/refinery create:migration create_user_table
```php
class Migration_create_user_table extends CI_Migration {

/**
* Run the migrations
*/
public function up()
{
$this->dbforge->add_field('id');
$this->dbforge->create_table('user');
}

/**
* Reverse the migrations
*/
public function down()
{
$this->dbforge->drop_table('user');
}
public function up()
{
$this->dbforge->add_field('id');
$this->dbforge->create_table('user');
}

public function down()
{
$this->dbforge->drop_table('user');
}

}
```
Expand All @@ -56,33 +50,35 @@ $ php vendor/bin/refinery create:migration add_name_in_user_table
```php
class Migration_add_name_in_user_table extends CI_Migration {

/**
* Run the migrations
*/
public function up()
{
$this->dbforge->add_column('user', array(
'name' => array(
'type' => 'VARCHAR',
'constraint' => '50',
'auto_increment' => FALSE,
'null' => FALSE,
'unsigned' => FALSE
)
));
}

/**
* Reverse the migrations
*/
public function down()
{
$this->dbforge->drop_column('user', 'name');
}
public function up()
{
$this->dbforge->add_column('user', array(
'name' => array(
'type' => 'VARCHAR',
'constraint' => '50',
'auto_increment' => FALSE,
'null' => FALSE,
'unsigned' => FALSE
)
));
}

public function down()
{
$this->dbforge->drop_column('user', 'name');
}

}
```

#### Available keywords

* create_*table*_table
* add_*column*_in_*table*_table
* modify_*column*_in_*table*_table
* delete_*column*_in_*table*_table


### Migrating all files in ```application/migrations``` directory

```bash
Expand Down Expand Up @@ -121,7 +117,7 @@ Migrate the database

* ```--revert``` - Number of times to revert from the list of migrations

**NOTE**: If an error occurs about URI, just include an equal sign ```=``` in ```$config['permitted_uri_chars']``` on ```application/config.php```
**NOTE**: If an error occurs about URI, just include an equal sign ```=``` in ```$config['permitted_uri_chars']``` on ```application/config.php```

#### ```migrate:reset```

Expand All @@ -145,7 +141,7 @@ Create a new migration file

* ```--sequential``` - Generates a migration file with a sequential identifier

**NOTE**: If you really want to use the sequential identifier, just change your ```$config['migration_type']``` in ```application/config/migration.php```
**NOTE**: If you really want to use the sequential identifier, just change your ```$config['migration_type']``` in ```application/config/migration.php```

* ```--type=[LENGTH]``` - Data type of the column

Expand Down
Empty file modified bin/refinery
100644 → 100755
Empty file.
54 changes: 22 additions & 32 deletions bin/refinery.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
<?php require realpath('vendor') . '/autoload.php';
<?php

use Rougin\Describe\Describe;
use Rougin\Refinery\CreateMigrationCommand;
use Rougin\Refinery\MigrateCommand;
use Rougin\Refinery\MigrateResetCommand;
use Rougin\SparkPlug\Instance;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
// Define the VENDOR path
$vendor = realpath('vendor');

/**
* Load the CodeIgniter instance
*/
// Include the Composer Autoloader
require $vendor . '/autoload.php';

$instance = new Instance();
$codeigniter = $instance->get();
$filePath = realpath(__DIR__ . '/../refinery.yml');
$directory = str_replace('/refinery.yml', '', $filePath);

/**
* Load Describe
*/
define('BLUEPRINT_FILENAME', $filePath);
define('BLUEPRINT_DIRECTORY', $directory);

require APPPATH . 'config/database.php';
// Load the CodeIgniter instance
$instance = new Rougin\SparkPlug\Instance();

$db['default']['driver'] = $db['default']['dbdriver'];
unset($db['default']['dbdriver']);
// Include the Inflector helper from CodeIgniter
require BASEPATH . 'helpers/inflector_helper.php';

$describe = new Describe($db['default']);
// Load the Blueprint library
$blueprint = include($vendor . '/rougin/blueprint/bin/blueprint.php');

/**
* Get the migrations.php from CodeIgniter
*/
if ($blueprint->hasError) {
exit($blueprint->showError());
}

$migration = array();
$migration['path'] = APPPATH . '/config/migration.php';
$migration['file'] = file_get_contents($migration['path']);
$blueprint->console->setName('Refinery');
$blueprint->console->setVersion('0.1.3');

$application = new Application('Refinery', '0.2.1');

$application->add(new MigrateCommand($codeigniter, $migration));
$application->add(new MigrateResetCommand($codeigniter));
$application->add(new CreateMigrationCommand($describe, $migration));
$application->run();
// Run the Refinery console application
$blueprint->console->run();
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": ["refinery", "database", "migrations", "php"],
"require": {
"php": ">=5.3.0",
"symfony/console": "*",
"rougin/blueprint": "*",
"rougin/describe": "*",
"rougin/spark-plug": "*"
},
Expand Down
6 changes: 6 additions & 0 deletions refinery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
paths:
templates: %%CURRENT_DIRECTORY%%/src/Templates
commands: %%CURRENT_DIRECTORY%%/src/Commands

namespaces:
commands: Rougin\Refinery\Commands
Loading

0 comments on commit a750f5b

Please sign in to comment.