Download the PHP package rougin/refinery without Composer
On this page you can find all versions of the php package rougin/refinery. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rougin/refinery
More information about rougin/refinery
Files in rougin/refinery
Package refinery
Short Description "Ready-to-eat" Codeigniter 3 migrations.
License MIT
Homepage https://roug.in/refinery/
Informations about the package refinery
Refinery
Refinery is a console-based package of Migrations Class for the Codeigniter 3. It uses the Describe package for retrieving the database tables for creating database migrations.
Installation
From an existing Codeigniter 3 project, the Refinery package can be installed through Composer:
Then configure the project's database connectivity settings:
[!NOTE] Although using database connection is not required in using
Refinery, this is only applicable when creating migration files based on an existing database. Please see Creating from database below for its usage.
Basic Usage
Creating migration files
To create a new database migration, kindly run the create command:
[!NOTE]
- The
Migrationclass underRefineryis directly extended onCI_Migration.- The created file will be in
migrationsdirectory underapplication. If it does not exists,Refinerywill automatically create the specified directory.
When creating database migrations, Refinery will try to guess the expected output of up and down methods of a migration file based on its name (e.g., add_name_in_users_table):
Please see the accepted keywords below when creating database migration files:
| Keyword | Description | Example |
|---|---|---|
add |
Adds new column to a table | add_name_in_users_table |
create |
Creates new table with id as the primary key |
create_users_table |
delete |
Deletes a column from a table | delete_name_in_users_table |
modify |
Updates a column of a table | modify_name_in_users_table |
Running the migrations
Kindly use the migrate command to use the files for database migrations:
When running this command, the target timestamp (--target) will always be the latest file in the migrations directory if not specified (e.g., add_name_in_users_table). Use the --target option to migrate to a specific version:
To rollback a database, kindly use the rollback command:
[!NOTE] Without a
--targetoption, therollbackwill only revert to its previous version (e.g.,create_users_table).
To reset back the database schema to version 0, the reset command can be used:
Creating from database
Refinery also allows to create a database migration based on the existing database table. Prior in creating its database migration, kindly ensure that the specified table already exists in the database schema:
After checking the database table exists, run the same create command with the --from-database option:
[!NOTE] The
--from-databaseoption only exists when creating files under thecreate_*_tableprefix.
Creating sequential migrations
By default, Refinery uses a timestamp prefix as its numbering style when creating migration files. To change it to a sequential numbering, kindly update the value of migration_type in the config/migration.php to sequential:
Then run the create command to generate a migration file in sequential migration:
Alternatively, the --sequential option can also be added in the create command to update the said configuration:
[!NOTE] When using the
--sequentialoption, themigration_typein theconfig/migration.phpis also set assequential.
Using refinery.yml
Refinery currently works out of the box after the configuration based on Installation. However, using a refinery.yml can be used for complex setups like specifying the new application path:
To create a refinery.yml, simply run the initialize command:
[!NOTE]
%%CURRENT_DIRECTORY%%is a placeholder variable which is the current directory ofrefinery.yml.
app_path
This property specifies the application directory. It may updated to any directory (e.g., ciacme/application, ciacme/config, etc.) as long it can detect the config/config.php file from the defined directory:
[!NOTE]
Refinerywill try to check the path specified inapp_pathif it is a validCodeigniter 3project. Then it will perform another check if theapplicationdirectory exists or if theconfigdirectory can be accessed directly from the directory defined inapp_path.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Credits
License
The MIT License (MIT). Please see LICENSE for more information.
All versions of refinery with dependencies
rougin/blueprint Version ~0.7
rougin/classidy Version ~0.1
rougin/describe Version ~1.8
rougin/spark-plug Version ~0.5