erykai/migration

Auto create tables database mysql

Fund package maintenance!
Erykai

v1.2.1 2023-04-06 00:36 UTC

This package is auto-updated.

Last update: 2024-12-06 04:16:19 UTC


README

Maintainer Source Code PHP from Packagist Latest Version Software License Quality Score Total Downloads

Auto create tables mysql

Installation

Composer:

"erykai/migration": "1.0.*"

Terminal

composer require erykai/migration

Create users.php

use Erikai\Migration;
require "vendor/autoload.php";
$create = new Migration();
$create->table('users');
$create->column('id')->type('int(11)')->default();
$create->column('name')->type('varchar(255)')->default();
$create->column('password')->type('text')->default()->null();
$create->column('email')->type('varchar(255)')->default();
$create->column('level')->type('int(11)')->default();
$create->column('profile')->type('varchar(255)')->default()->null();
$create->column('cover')->type('varchar(255)')->default()->null();
$create->column('created_at')->type('timestamp')->default("current_timestamp()");
$create->column('updated_at')->type('timestamp')->default("current_timestamp() ON UPDATE current_timestamp()");
$create->save();
$create->primary('id');
$create->autoIncrement('id');

Create posts_categories.php

use Erikai\Migration;
require "vendor/autoload.php";
$create = new Migration();
$create->table('posts_categories');
$create->column('id')->type('int(11)')->default();
$create->column('id_user')->type('int(11)')->default();
$create->column('title')->type('varchar(255)')->default();
$create->column('created_at')->type('timestamp')->default("current_timestamp()");
$create->column('updated_at')->type('timestamp')->default("current_timestamp() ON UPDATE current_timestamp()");
$create->save();
$create->primary('id');
$create->autoIncrement('id');
$create->addKey('users_categories', "id_user", "users", "id");

Create posts.php

use Erikai\Migration;
require "vendor/autoload.php";
$create = new Migration();
$create->table('posts');
$create->column('id')->type('int(11)')->default();
$create->column('id_user')->type('int(11)')->default();
$create->column('id_category')->type('int(11)')->default();
$create->column('title')->type('varchar(255)')->default();
$create->column('description')->type('text')->default();
$create->column('cover')->type('varchar(255)')->default()->null();
$create->column('created_at')->type('timestamp')->default("current_timestamp()");
$create->column('updated_at')->type('timestamp')->default("current_timestamp() ON UPDATE current_timestamp()");
$create->save();
$create->primary('id');
$create->autoIncrement('id');
$create->addKey('users_posts', "id_user", "users", "id");
$create->addKey('posts_categories', "id_category", "posts_categories", "id");

Contribution

All contributions will be analyzed, if you make more than one change, make the commit one by one.

Support

If you find faults send an email reporting to webav.com.br@gmail.com.

Credits

License

The MIT License (MIT). Please see License for more information.