feat: bigint to ulid
This commit is contained in:
parent
1216c8a073
commit
5d2f4d0ee0
|
|
@ -13,7 +13,7 @@ return new class extends Migration
|
||||||
{
|
{
|
||||||
Schema::create('subscriptions', function (Blueprint $table) {
|
Schema::create('subscriptions', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('user_id');
|
$table->foreignUlid('user_id');
|
||||||
$table->string('type');
|
$table->string('type');
|
||||||
$table->string('stripe_id')->unique();
|
$table->string('stripe_id')->unique();
|
||||||
$table->string('stripe_status');
|
$table->string('stripe_status');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if (! Schema::hasTable('subscriptions')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::statement('DROP INDEX IF EXISTS subscriptions_user_id_stripe_status_index');
|
||||||
|
DB::statement('ALTER TABLE subscriptions ALTER COLUMN user_id TYPE CHAR(26) USING user_id::text');
|
||||||
|
DB::statement('CREATE INDEX subscriptions_user_id_stripe_status_index ON subscriptions (user_id, stripe_status)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if (! Schema::hasTable('subscriptions')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::statement('DROP INDEX IF EXISTS subscriptions_user_id_stripe_status_index');
|
||||||
|
DB::statement('ALTER TABLE subscriptions ALTER COLUMN user_id TYPE BIGINT USING user_id::bigint');
|
||||||
|
DB::statement('CREATE INDEX subscriptions_user_id_stripe_status_index ON subscriptions (user_id, stripe_status)');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue