Skip to content

Commit 4ede2be

Browse files
fix(database): make migrations run on MySQL and MariaDB (#197)
* Update 2026_06_11_232520_create_connected_accounts_tables.php * Update 2026_06_12_144124_create_posts_and_account_sets_tables.php * Update 2026_06_13_000000_create_posting_schedules_tables.php * Update 2026_06_28_000000_add_segments_to_posts.php * Update 2026_07_01_000001_create_usage_tables.php * fix(database): allow longer usage event categories --------- Co-authored-by: Omar Herri <herri.omar@gmail.com>
1 parent efd509f commit 4ede2be

5 files changed

Lines changed: 12 additions & 6 deletions

‎database/migrations/2026_06_11_232520_create_connected_accounts_tables.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function up(): void
2525
$table->timestamp('last_refreshed_at')->nullable();
2626
$table->timestamps();
2727

28-
$table->unique(['workspace_id', 'platform', 'remote_account_id']);
28+
$table->unique(['workspace_id', 'platform', 'remote_account_id'], 'connected_accounts_workspace_platform_remote_unique');
2929
});
3030

3131
Schema::create('connected_account_secrets', function (Blueprint $table) {

‎database/migrations/2026_06_12_144124_create_posts_and_account_sets_tables.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare(strict_types=1);
44

55
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Query\Expression;
67
use Illuminate\Database\Schema\Blueprint;
78
use Illuminate\Support\Facades\Schema;
89

@@ -32,7 +33,7 @@ public function up(): void
3233
$table->foreignUuid('workspace_id')->constrained('workspaces')->cascadeOnDelete();
3334
$table->foreignUuid('account_set_id')->nullable()->constrained('account_sets')->nullOnDelete();
3435
$table->foreignUuid('author_id')->constrained('users')->cascadeOnDelete();
35-
$table->text('base_text')->default('');
36+
$table->text('base_text')->default(new Expression("('')"));
3637
$table->string('status')->default('draft');
3738
$table->timestamp('scheduled_at')->nullable();
3839
$table->timestamp('published_at')->nullable();
@@ -47,7 +48,7 @@ public function up(): void
4748
$table->foreignUuid('post_id')->constrained('posts')->cascadeOnDelete();
4849
$table->foreignUuid('connected_account_id')->constrained('connected_accounts')->cascadeOnDelete();
4950
$table->string('platform');
50-
$table->json('sections')->default('[]');
51+
$table->json('sections')->default(new Expression("('[]')"));
5152
$table->json('content_override')->nullable();
5253
$table->boolean('auto_split')->default(true);
5354
$table->string('status')->default('pending');

‎database/migrations/2026_06_13_000000_create_posting_schedules_tables.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function up(): void
2626
$table->unsignedInteger('position')->default(0);
2727
$table->timestamps();
2828

29-
$table->unique(['posting_schedule_id', 'weekday', 'hour', 'minute']);
29+
$table->unique(['posting_schedule_id', 'weekday', 'hour', 'minute'], 'posting_slots_schedule_time_unique');
3030
});
3131
}
3232

‎database/migrations/2026_06_28_000000_add_segments_to_posts.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Query\Expression;
45
use Illuminate\Database\Schema\Blueprint;
56
use Illuminate\Support\Facades\Schema;
67

@@ -9,7 +10,10 @@
910
public function up(): void
1011
{
1112
Schema::table('posts', function (Blueprint $table): void {
12-
$table->json('segments')->nullable()->default('[]')->after('base_text');
13+
$table->json('segments')
14+
->nullable()
15+
->default(new Expression("('[]')"))
16+
->after('base_text');
1317
});
1418
}
1519

‎database/migrations/2026_07_01_000001_create_usage_tables.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public function up(): void
3636
$table->foreignUuid('workspace_id')->constrained('workspaces')->cascadeOnDelete();
3737
$table->date('period_start');
3838
$table->date('period_end');
39-
$table->string('category');
39+
// 64 chars keeps the composite unique index under MySQL's 3072-byte key limit.
40+
$table->string('category', 64);
4041
// NOT NULL: a UNIQUE index treats NULLs as distinct, which would let
4142
// platform-less ops create duplicate rows. Platform-less ops use 'none'.
4243
$table->string('platform');

0 commit comments

Comments
 (0)