Created
August 27, 2023 11:33
-
-
Save Swader/f8bbb0aa5f88d1151fe2ca02fe6a8bf3 to your computer and use it in GitHub Desktop.
ChatGPT Migration Output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreateEditionsTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('editions', function (Blueprint $table) { | |
$table->id(); | |
$table->unsignedBigInteger('newsletter'); | |
$table->string('subject'); | |
$table->timestamps(); | |
$table->foreign('newsletter')->references('id')->on('newsletters')->onDelete('restrict')->onUpdate('restrict'); | |
}); | |
} | |
public function down() | |
{ | |
Schema::dropIfExists('editions'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreateEditionSectionsTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('edition_sections', function (Blueprint $table) { | |
$table->id(); | |
$table->unsignedBigInteger('edition'); | |
$table->unsignedBigInteger('section'); | |
$table->mediumText('frontmatter')->nullable(); | |
$table->mediumText('hz_pills_filled')->nullable(); | |
$table->timestamps(); | |
$table->foreign('edition')->references('id')->on('editions')->onDelete('cascade')->onUpdate('cascade'); | |
$table->foreign('section')->references('id')->on('sections')->onDelete('cascade')->onUpdate('cascade'); | |
}); | |
} | |
public function down() | |
{ | |
Schema::dropIfExists('edition_sections'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreateEditorsTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('editors', function (Blueprint $table) { | |
$table->unsignedBigInteger('user'); | |
$table->unsignedInteger('role'); | |
$table->unsignedTinyInteger('accepted')->default(0); | |
$table->unsignedBigInteger('invited_by'); | |
$table->unsignedInteger('newsletter'); | |
$table->dateTime('invited_on'); | |
$table->dateTime('accepted_on')->nullable(); | |
$table->timestamps(); | |
$table->foreign('user')->references('id')->on('users')->onDelete('restrict')->onUpdate('cascade'); | |
$table->foreign('role')->references('id')->on('roles')->onDelete('restrict')->onUpdate('cascade'); | |
$table->foreign('invited_by')->references('id')->on('users')->onDelete('restrict')->onUpdate('cascade'); | |
}); | |
} | |
public function down() | |
{ | |
Schema::dropIfExists('editors'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreateLinksTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('links', function (Blueprint $table) { | |
$table->id(); | |
$table->string('url', 255); | |
$table->string('title', 255); | |
$table->mediumText('summary')->nullable(); | |
$table->unsignedBigInteger('sec_ed')->nullable(); | |
$table->timestamps(); | |
$table->foreign('sec_ed')->references('id')->on('edition_sections')->onDelete('set null')->onUpdate('no action'); | |
}); | |
} | |
public function down() | |
{ | |
Schema::dropIfExists('links'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreatePlansTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('plans', function (Blueprint $table) { | |
$table->id(); | |
$table->string('name'); | |
$table->string('slug')->unique(); | |
$table->mediumText('description')->nullable(); | |
$table->unsignedInteger('price_month'); | |
$table->unsignedInteger('price_nl'); | |
$table->unsignedInteger('price_per_user'); | |
$table->unsignedInteger('annual_discount_percent'); | |
$table->timestamps(); | |
}); | |
} | |
public function down() | |
{ | |
Schema::dropIfExists('plans'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreateRolesTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('roles', function (Blueprint $table) { | |
$table->id(); | |
$table->string('title')->unique(); | |
$table->string('slug')->unique(); | |
$table->mediumText('description')->nullable(); | |
$table->timestamps(); | |
}); | |
} | |
public function down() | |
{ | |
Schema::dropIfExists('roles'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreateSectionsTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('sections', function (Blueprint $table) { | |
$table->id(); | |
$table->string('heading'); | |
$table->mediumText('frontmatter')->nullable(); | |
$table->json('style_options')->nullable(); | |
$table->unsignedBigInteger('newsletter'); | |
$table->json('hz_pills')->nullable(); | |
$table->timestamps(); | |
$table->foreign('newsletter')->references('id')->on('newsletters')->onDelete('cascade')->onUpdate('cascade'); | |
}); | |
} | |
public function down() | |
{ | |
Schema::dropIfExists('sections'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class ModifyUsersTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::table('users', function (Blueprint $table) { | |
$table->unsignedInteger('plan')->default(0)->after('updated_at'); | |
$table->foreign('plan')->references('id')->on('plans')->onDelete('no action')->onUpdate('no action'); | |
}); | |
} | |
public function down() | |
{ | |
Schema::table('users', function (Blueprint $table) { | |
$table->dropForeign(['plan']); | |
$table->dropColumn('plan'); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment