From 67c377fe1d87bfb127bcbfa952e9119bd341d4e8 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Thu, 27 Dec 2018 01:05:36 -0500 Subject: * Playlists: Set up many to many relationship --- .../2018_12_27_052646_create_playlist_table.php | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 laravel/database/migrations/2018_12_27_052646_create_playlist_table.php (limited to 'laravel/database') diff --git a/laravel/database/migrations/2018_12_27_052646_create_playlist_table.php b/laravel/database/migrations/2018_12_27_052646_create_playlist_table.php new file mode 100644 index 0000000..6b68c7f --- /dev/null +++ b/laravel/database/migrations/2018_12_27_052646_create_playlist_table.php @@ -0,0 +1,41 @@ +increments('id'); + $table->text('name'); + $table->timestamps(); + }); + Schema::create('playlist_song', function(Blueprint $table) { + $table->increments('id'); + $table->unsignedInteger('playlist_id'); + $table->unsignedInteger('song_id'); + $table->unique(['playlist_id', 'song_id']); + $table->foreign('playlist_id')->references('id')->on('playlists'); + $table->foreign('song_id')->references('id')->on('songs'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('playlist_song'); + Schema::dropIfExists('playlists'); + } +} -- cgit 1.4.1