Questions tagged «laravel-migrations»

9
向迁移中的现有表添加新列
我不知道如何使用Laravel框架向现有数据库表添加新列。 我尝试使用...来编辑迁移文件。 <?php public function up() { Schema::create('users', function ($table) { $table->integer("paid"); }); } 在终端中,我执行php artisan migrate:install和migrate。 如何添加新列?

9
Laravel迁移更改以使列为空
我使用unsigned创建了迁移user_id。如何user_id在新迁移中进行编辑以使其同样成功nullable()? Schema::create('throttle', function(Blueprint $table) { $table->increments('id'); // this needs to also be nullable, how should the next migration be? $table->integer('user_id')->unsigned(); }

4
Laravel未知列'updated_at'
我刚开始使用Laravel并收到以下错误: 未知列'updated_at'插入gebruikers(naam,wachtwoord,updated_at,created_at) 我知道错误是由于在迁移表时出现在时间戳列中,但我没有使用该updated_at字段。我遵循Laravel教程时曾经使用它,但是现在我正在制作(或尝试制作)自己的东西。即使不使用时间戳,我也会收到此错误。我似乎找不到使用它的地方。这是代码: 控制者 public function created() { if (!User::isValidRegister(Input::all())) { return Redirect::back()->withInput()->withErrors(User::$errors); } // Register the new user or whatever. $user = new User; $user->naam = Input::get('naam'); $user->wachtwoord = Hash::make(Input::get('password')); $user->save(); return Redirect::to('/users'); } 路线 Route::get('created', 'UserController@created'); 模型 public static $rules_register = [ 'naam' => 'unique:gebruikers,naam' ]; public static …

4
Laravel Schema onDelete设置为null
无法弄清楚如何在Laravel中的表上设置适当的onDelete约束。(我正在使用SqLite) $table->...->onDelete('cascade'); // works $table->...->onDelete('null || set null'); // neither of them work 我进行了3次迁移,创建了Gallery表: Schema::create('galleries', function($table) { $table->increments('id'); $table->string('name')->unique(); $table->text('path')->unique(); $table->text('description')->nullable(); $table->timestamps(); $table->engine = 'InnoDB'; }); 创建图片表: Schema::create('pictures', function($table) { $table->increments('id'); $table->text('path'); $table->string('title')->nullable(); $table->text('description')->nullable(); $table->integer('gallery_id')->unsigned(); $table->foreign('gallery_id') ->references('id')->on('galleries') ->onDelete('cascade'); $table->timestamps(); $table->engine = 'InnoDB'; }); 将图库表链接到图片: Schema::table('galleries', function($table) { // id of …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.