Skip to content

Instantly share code, notes, and snippets.

@Swader
Last active September 2, 2023 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swader/a892bd87553036142aa0073c2ef0d4f5 to your computer and use it in GitHub Desktop.
Save Swader/a892bd87553036142aa0073c2ef0d4f5 to your computer and use it in GitHub Desktop.
Cursor Migration Output
<?php
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->unsignedBigInteger('edition');
$table->unsignedBigInteger('section');
$table->mediumText('frontmatter')->nullable();
$table->mediumText('hz_pills_filled')->nullable();
$table->id();
$table->foreign('edition')->references('id')->on('editions')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('section')->references('id')->on('sections')->onDelete('cascade')->onUpdate('cascade');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('edition_sections');
}
}
<?php
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', 150);
$table->foreign('newsletter')->references('id')->on('newsletters')->onDelete('restrict')->onUpdate('restrict');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('editions');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNewslettersTable extends Migration
{
public function up()
{
Schema::create('newsletters', function (Blueprint $table) {
$table->id();
$table->string('title', 150);
$table->unsignedBigInteger('admin');
$table->dateTime('created');
$table->json('settings');
$table->foreign('admin')->references('id')->on('users')->onDelete('restrict')->onUpdate('cascade');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('newsletters');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid', 255)->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetTokensTable extends Migration
{
public function up()
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email', 255)->primary();
$table->string('token', 255);
$table->timestamp('created_at')->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('password_reset_tokens');
}
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePersonalAccessTokensTable extends Migration
{
public function up()
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->string('tokenable_type', 255);
$table->unsignedBigInteger('tokenable_id');
$table->string('name', 255);
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
$table->index(['tokenable_type', 'tokenable_id']);
});
}
public function down()
{
Schema::dropIfExists('personal_access_tokens');
}
}
<?php
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', 45);
$table->string('slug', 45)->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');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->id();
$table->string('title', 45)->unique();
$table->string('slug', 45)->unique();
$table->mediumText('description')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('roles');
}
}
<?php
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', 45);
$table->mediumText('frontmatter')->nullable();
$table->json('style_options')->nullable();
$table->unsignedBigInteger('newsletter');
$table->json('hz_pills')->nullable();
$table->foreign('newsletter')->references('id')->on('newsletters')->onDelete('cascade')->onUpdate('cascade');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('sections');
}
}
<?php
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->unsignedBigInteger('plan')->default(0)->after('created_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