From 80423301c45d028e2fa1146b8dfb21828c887efe Mon Sep 17 00:00:00 2001 From: Doar Mihai Date: Sun, 19 Jul 2026 16:48:03 +0300 Subject: [PATCH] feat: add published_url column to posts Co-Authored-By: Claude Sonnet 5 --- app/Models/Post.php | 1 + ...34706_add_published_url_to_posts_table.php | 22 +++++++++++++++++++ tests/Feature/PostModelTest.php | 14 ++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 database/migrations/2026_07_19_134706_add_published_url_to_posts_table.php diff --git a/app/Models/Post.php b/app/Models/Post.php index a1e9043..c1802a1 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -25,6 +25,7 @@ class Post extends Model 'body', 'status', 'scheduled_at', + 'published_url', ]; protected $casts = [ diff --git a/database/migrations/2026_07_19_134706_add_published_url_to_posts_table.php b/database/migrations/2026_07_19_134706_add_published_url_to_posts_table.php new file mode 100644 index 0000000..e505253 --- /dev/null +++ b/database/migrations/2026_07_19_134706_add_published_url_to_posts_table.php @@ -0,0 +1,22 @@ +string('published_url')->nullable()->after('scheduled_at'); + }); + } + + public function down(): void + { + Schema::table('posts', function (Blueprint $table) { + $table->dropColumn('published_url'); + }); + } +}; diff --git a/tests/Feature/PostModelTest.php b/tests/Feature/PostModelTest.php index f473e3a..0c9ae21 100644 --- a/tests/Feature/PostModelTest.php +++ b/tests/Feature/PostModelTest.php @@ -83,3 +83,17 @@ test('deleting a social account nulls out the post link but keeps the post', fun ->not->toBeNull() ->social_account_id->toBeNull(); }); + +test('a post can store a published_url', function () { + $post = Post::factory()->create(['published_url' => null]); + + $post->update(['published_url' => 'https://example.com/2026/07/my-post']); + + expect($post->fresh()->published_url)->toBe('https://example.com/2026/07/my-post'); +}); + +test('published_url defaults to null', function () { + $post = Post::factory()->create(); + + expect($post->fresh()->published_url)->toBeNull(); +});