Skip to content

Commit ad61c82

Browse files
authored
Merge pull request #18 from thefireflytech/migration-constraint
Migration constraint
2 parents 1d87e24 + 659f340 commit ad61c82

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

database/migrations/create_blog_tables.php.stub

+12-12
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ return new class () extends Migration {
4242

4343
Schema::create(config('filamentblog.tables.prefix').'category_'.config('filamentblog.tables.prefix').'post', function (Blueprint $table) {
4444
$table->id();
45-
$table->foreignIdFor(Firefly\FilamentBlog\Models\Post::class)
46-
->constrained()
45+
$table->foreignId( "post_id")
46+
->constrained(table: config('filamentblog.tables.prefix').'posts')
4747
->cascadeOnDelete();
48-
$table->foreignIdFor(Firefly\FilamentBlog\Models\Category::class)
49-
->constrained()
48+
$table->foreignId("category_id")
49+
->constrained(table: config('filamentblog.tables.prefix').'categories')
5050
->cascadeOnDelete();
5151
$table->timestamps();
5252
});
5353

5454
Schema::create(config('filamentblog.tables.prefix').'seo_details', function (Blueprint $table) {
5555
$table->id();
56-
$table->foreignIdFor(Firefly\FilamentBlog\Models\Post::class)
57-
->constrained()
56+
$table->foreignId("post_id")
57+
->constrained(table: config('filamentblog.tables.prefix').'posts')
5858
->cascadeOnDelete();
5959
$table->string('title');
6060
$table->json('keywords')->nullable();
@@ -65,8 +65,8 @@ return new class () extends Migration {
6565
Schema::create(config('filamentblog.tables.prefix').'comments', function (Blueprint $table) {
6666
$table->id();
6767
$table->foreignId(config('filamentblog.user.foreign_key'));
68-
$table->foreignIdFor(Firefly\FilamentBlog\Models\Post::class)
69-
->constrained()
68+
$table->foreignId("post_id")
69+
->constrained(table: config('filamentblog.tables.prefix').'posts')
7070
->cascadeOnDelete();
7171
$table->text('comment');
7272
$table->boolean('approved')->default(false);
@@ -90,11 +90,11 @@ return new class () extends Migration {
9090

9191
Schema::create(config('filamentblog.tables.prefix').'post_'.config('filamentblog.tables.prefix').'tag', function (Blueprint $table) {
9292
$table->id();
93-
$table->foreignIdFor(Firefly\FilamentBlog\Models\Post::class)
94-
->constrained()
93+
$table->foreignId("post_id")
94+
->constrained(table: config('filamentblog.tables.prefix').'posts')
9595
->cascadeOnDelete();
96-
$table->foreignIdFor(Firefly\FilamentBlog\Models\Tag::class)
97-
->constrained()
96+
$table->foreignId("tag_id")
97+
->constrained(table: config('filamentblog.tables.prefix').'tags')
9898
->cascadeOnDelete();
9999
$table->timestamps();
100100
});

0 commit comments

Comments
 (0)