mysql/schematic 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mysql/schematic

Composer 安装命令:

composer require mysql/schematic

包简介

A simple MySQL migration management tool in PHP, create and update databases automatically with a config json file without having to use inbuilt ORM functions.

README 文档

README

NO LONGER MAINTAINED

Due to the fact that Schematic was never truly fully completed with all the features I wanted it to have, I'm shelving it for the time being, if anyone would like to become the new active contributer let me know. However I've now moved on to Laravel as my main framework and Laravel migrations have now taken over from Schematic.

A database migrations tool, allows for easy database maintenance in a way that is easy to setup in a continuous integration environment.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License Bitdeli Badge ###Install locally via Composer

{
    require: {
        "mysql/schematic": "1.*.*"
    }
}

###Install it Globally

  • Run the following commands:

Download the PHAR file:

wget --no-check-certificate https://github.com/andrefigueira/Schematic/raw/master/schematic.phar

Make the PHAR package executable

chmod +x schematic.phar

Move it to the user bin folder

mv schematic.phar /usr/local/bin/schematic

Then use Schematic

schematic

Schematic will now be available globally for you!

###Schema format

Schema is defined in schema files, these must be stored in the schema folder in json files representing the table they are for, e.g. (Make sure that you create the schema folder in the root of your project)

~/ProjectFolder/schemas/table_name.yaml

The schema file contains all of the configuration of the database in order to create it or amend it, see an example below.

In the current version you need to pass a type and null through always, you pass the length in parenthesis on the type field.

Schematic uses all of the base MySQL values so you just need to put them into this file and they will work, if you spell something incorrectly, it will stop running and throw and exception.

###Example Schema

schematic:
    name: Schematic
    version: 1.4.5
database:
    general:
        name: schematic
        charset: utf8
        collation: utf8_general_ci
        engine: InnoDB
    tables:
        hello_world:
            fields:
                id:
                    type: int(11)
                    'null': false
                    unsigned: true
                    autoIncrement: true
                    index: 'PRIMARY KEY'
                client_id:
                    type: int(24)
                    'null': false
                    unsigned: true
                    autoIncrement: false
                name:
                    type: varchar(128)
                    'null': false
                    unsigned: false
                    autoIncrement: false
                    rename: full_name
                description:
                    type: varchar(256)
                    'null': false
                    unsigned: false
                    autoIncrement: false
                created_date:
                    type: datetime
                    'null': false
                    unsigned: false
                    autoIncrement: false

Note that currently foreign keys are only added, but not removed, If created a new database with constraints, you must run the update twice to add the constraints.

Usage:

schematic [options] command [arguments]

Options:

--help -h Display this help message.

--quiet -q Do not output any message.

--verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

--version -V Display this application version.

--ansi Force ANSI output.

--no-ansi Disable ANSI output.

--no-interaction -n Do not ask any interactive question.

Available commands:

help Displays help for a command

list Lists commands

Migrations

migrations:execute Executes the database migration based on the JSON schema files

migrations:generate Generates the database schema JSON files

migrations:mapping Generates the database schema based on an existing database

The script also creates a log of all of the database changes which are made.

统计信息

  • 总下载量: 731
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 6
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2013-12-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固