1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Database\Migrations\Migration;
- class CreatePostsTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('posts', function(Blueprint $table) {
- $table->increments('id');
- $table->timestamps();
- $table->string('titre', 80);
- $table->text('contenu');
- $table->integer('user_id')->unsigned();
- $table->foreign('user_id')
- ->references('id')
- ->on('users')
- ->onDelete('restrict')
- ->onUpdate('restrict');
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table('posts', function(Blueprint $table) {
- $table->dropForeign('posts_user_id_foreign');
- });
- Schema::drop('posts');
- }
- }
|