The Elegant Way of Building Full-Featured Web Applications
Simple & Clean Framework
You Talk About Simplicity Or Performance? You Will Fit Right In..
Enjoy The Elegant Syntax, Use Powerful Features as Container,
Code Generator, RESTful Routing, Active Record, Finders,
Schema Builder, Migrations Without Sacrificing the
Performance.
Create your database version control using Cygnite Migration commands. The Migration commands gives you convenient way to alter your database schema over time and stay you up-to-date. In most of the database driven application we often need to keep track of database schema changes, similar thing as we do with our source code (with git, svn etc.). For example once your application is in production server, you may want to add a new column or add a index to the table. This is where Cygnite Migration tool comes to action, now you can keep track of your alteration with Cygnite Migration tool.
Cygnite migration tool is inspired by Ruby on Rails migration. Migrations are coupled with Cygnite Schema Builder to manage your database schema.
If you are running migration commands for the first time you need to execute migrate:init command. It will create a migrations table in your database,it holds all migration information ran in your application
You can also generate your first migration file using same init command. You just need to pass extra parameter in init command.
cd /var/www/cygnite/console/bin/
php craft migrate:init user
The above command will generate a skeleton migration class with timestamp prefix into src/Apps/Resources/Database/Migrations/xxxx_user.php. Class will look like below.
use Cygnite\Database\Table\Schema;
class User
{
/**
* Run the migrations up.
* @return void
*/
public function up()
{
//Your schema to migrate
Schema::make('user', function ($table)
{
$table->create([
['column'=> 'id', 'type' => 'int', 'length' => 11,
'increment' => true, 'key' => 'primary'],
/*..Add columns to your table schema .*/
['column'=> 'created_at', 'type' => 'datetime'],
['column'=> 'updated_at', 'type' => 'datetime'],
], 'InnoDB', 'latin1');
});
}
/**
* Revert back your migrations.
* @return void
*/
public function down()
{
//Roll back your changes done by up method.
Schema::make('user', function ($table)
{
$table->drop();
});
}
}
In the above migration class up method to run your migration and down method to rollback migration changes made in up method. You can make use of Schema Builder functions to alter/drop your table schema.
[Note: You can specify the database connection name where you wish to build the schema using on() method $table->on('products');. If you don't specify the database connection then Schema Builder will use default connection to build your schema.
After doing appropriate changes to your latest migration file, you should issue migration command to reflect changes into your database.
php craft migrate
Above command will up your migration into database and also create a new version in your database migrations table.
[Note: If you running your application in higher version of MYSQL (example: MYSQL 5.7.9) you need to specify the default value for created_at, updated_at fields in length value.]
Rollback your latest migration changes using down method.
/**
* Revert back your migrations.
* @return void
*/
public function down()
{
//Roll back your changes done by up method.
Schema::make($this,function ($table)
{
$table->on('products');
$table->drop();
});
}
cd var/www/cygnite/console/bin/
php craft migrate down
Testimonials
Pongsakorn Ekaksorn -
Cygnite Framework is a very simple but powerful application framework with very short learning curve. It is just few months now I started working with cygnite framework, found it is amazingly fast, lightweight and easy to use. It helped me to build my application in very short time and fulfilled my basic requirement. Waiting for version 2.0 release to use it's extended features.
Michael
Cygnite framework made my job simple and enjoyable. I am able to complete my project short span of time. Thanks.
Sathya Narayanan
Cygnite seems to be awesome as a light weight and medium scale framework.
Follow Us On Facebook Twitter Google+Linkedin
Released Under The MIT Public License. Copyrights @2012-2017. Powered by- Sanjoy Dey Productions.