相关疑难解决方法(0)

SQLSTATE [HY000]:常规错误:1005无法创建表 - Laravel 4

当我做php artisan migrate时,我收到此错误.我的迁移文件有什么问题吗?或者我的模型可能编码错误吗?但即使模型中存在问题,迁移也应该有效吗?

[Exception]                                                                  
  SQLSTATE[HY000]: General error: 1005 Can't create table 'festival_aid.#sql-  
  16643_2033' (errno: 150) (SQL: alter table `gigs` add constraint gigs_band_  
  id_foreign foreign key (`band_id`) references `bands` (`band_id`) on delete  
   cascade) (Bindings: array (                                                 
  ))

[PDOException]                                                               
  SQLSTATE[HY000]: General error: 1005 Can't create table 'festival_aid.#sql-  
  16643_2033' (errno: 150)
Run Code Online (Sandbox Code Playgroud)

演出迁移

public function up()
    {
        Schema::create('gigs', function($table)
        {
            $table->increments('gig_id');

            $table->dateTime('gig_startdate');

            $table->integer('band_id')->unsigned();
            $table->integer('stage_id')->unsigned();

            $table->foreign('band_id')
                ->references('band_id')->on('bands')
                ->onDelete('cascade');

            $table->foreign('stage_id')
                ->references('stage_id')->on('stages')
                ->onDelete('cascade');
        });

    public function down()
    {
        Schema::table('gigs', function($table)
        {
            Schema::drop('gigs');
            $table->dropForeign('gigs_band_id_foreign');
            $table->dropForeign('gigs_stage_id_foreign');
        });
    }
Run Code Online (Sandbox Code Playgroud)

乐队迁移 …

php migration laravel laravel-4

11
推荐指数
2
解决办法
3万
查看次数

标签 统计

laravel ×1

laravel-4 ×1

migration ×1

php ×1