承接 yzh52521/migrate-schema 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yzh52521/migrate-schema

最新稳定版本:v1.0.1

Composer 安装命令:

composer require yzh52521/migrate-schema

包简介

易使用漂亮的数据库迁移代码构建器

README 文档

README

composer require yzh52521/migrate-schema

使用

// 创建表
Schema::create($this->getAdapter(), '表名', function (Blueprint $table) {
    // 迁移代码
});

// 修改表
Schema::table($this->getAdapter(), '表名', function (Blueprint $table) {
    // 迁移代码
});

可用的字段定义方法

命令 描述
$table->id(); 定义一个bigint 并命名为id的主键
$table->bigInteger('votes'); 相当于 BIGINT
$table->binary('data'); 相当于 BLOB
$table->boolean('confirmed'); 相当于 BOOLEAN
$table->char('name', 100); 相当于带有长度的 CHAR
$table->date('created_at'); 相当于 DATE
$table->dateTime('created_at'); 相当于 DATETIME
$table->decimal('amount', 8, 2); 相当于带有精度与基数 DECIMAL
$table->double('amount', 8, 2); 相当于带有精度与基数 DOUBLE (think-migration 3.1.x)
$table->float('amount', 8, 2); 相当于带有精度与基数 FLOAT (think-migration 3.1.x)
$table->enum('level', ['easy', 'hard']); 相当于 ENUM
$table->set('level', ['easy', 'hard']); 相当于 SET (think-migration 3.1.x)
$table->geometry('positions'); 相当于 GEOMETRY
$table->integer('votes'); 相当于 INTEGER
$table->json('options'); 相当于 JSON
$table->jsonb('options'); 相当于 JSONB
$table->lineString('positions'); 相当于 LINESTRING
$table->longText('description'); 相当于 LONGTEXT
$table->mediumInteger('votes'); 相当于 MEDIUMINT
$table->mediumText('description'); 相当于 MEDIUMTEXT
$table->point('position'); 相当于 POINT
$table->polygon('positions'); 相当于 POLYGON
$table->smallInteger('votes'); 相当于 SMALLINT
$table->softDeletes(); 相当于为软删除添加一个可空的 delete_time 字段
$table->string('name', 100); 相当于带长度的 VARCHAR
$table->text('description'); 相当于 TEXT
$table->time('sunrise'); 相当于 TIME
$table->timestamp('added_on'); 相当于 TIMESTAMP
$table->timestamps(); 相当于可空的 create_time 和 update_time TIMESTAMP
$table->tinyInteger('votes'); 相当于 TINYINT
$table->unsignedBigInteger('votes'); 相当于 Unsigned BIGINT
$table->unsignedDecimal('amount', 8, 2); 相当于带有精度和基数的 UNSIGNED DECIMAL
$table->unsignedInteger('votes'); 相当于 Unsigned INT
$table->unsignedMediumInteger('votes'); 相当于 Unsigned MEDIUMINT
$table->unsignedSmallInteger('votes'); 相当于 Unsigned SMALLINT
$table->unsignedTinyInteger('votes'); 相当于 Unsigned TINYINT
$table->uuid('id'); 相当于 UUID
$table->year('birth_year'); 相当于 YEAR

查看使用示例

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-05