@@ -245,6 +245,70 @@ public function output_also_updates_pivot_table_migration(): void
245
245
$ this ->assertEquals (['updated ' => [$ model_migration , $ pivot_migration ]], $ this ->subject ->output ($ tree , true ));
246
246
}
247
247
248
+ #[Test]
249
+ public function output_also_creates_constraints_for_pivot_table_migration_for_ulids (): void
250
+ {
251
+ $ this ->app ->config ->set ('blueprint.use_constraints ' , true );
252
+
253
+ $ this ->filesystem ->expects ('stub ' )
254
+ ->with ('migration.stub ' )
255
+ ->andReturn ($ this ->stub ('migration.stub ' ));
256
+
257
+ $ now = Carbon::now ();
258
+ Carbon::setTestNow ($ now );
259
+
260
+ $ journey_model_migration = str_replace ('timestamp ' , $ now ->copy ()->subSeconds (2 )->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
261
+ $ diary_model_migration = str_replace ('timestamp ' , $ now ->copy ()->subSecond ()->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diaries_table.php ' );
262
+ $ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diary_journey_table.php ' );
263
+
264
+ $ this ->filesystem ->expects ('exists ' )->times (3 )->andReturn (false );
265
+
266
+ $ this ->filesystem ->expects ('put ' )
267
+ ->with ($ journey_model_migration , $ this ->fixture ('migrations/belongs-to-many-key-constraints-using-ulid-columns-journey-model.php ' ));
268
+ $ this ->filesystem ->expects ('put ' )
269
+ ->with ($ diary_model_migration , $ this ->fixture ('migrations/belongs-to-many-key-constraints-using-ulid-columns-diary-model.php ' ));
270
+
271
+ $ this ->filesystem ->expects ('put ' )
272
+ ->with ($ pivot_migration , $ this ->fixture ('migrations/belongs-to-many-pivot-key-constraints-using-ulid-columns.php ' ));
273
+
274
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/belongs-to-many-using-ulids.yaml ' ));
275
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
276
+
277
+ $ this ->assertEquals (['created ' => [$ journey_model_migration , $ diary_model_migration , $ pivot_migration ]], $ this ->subject ->output ($ tree ));
278
+ }
279
+
280
+ #[Test]
281
+ public function output_also_creates_constraints_for_pivot_table_migration_for_uuids (): void
282
+ {
283
+ $ this ->app ->config ->set ('blueprint.use_constraints ' , true );
284
+
285
+ $ this ->filesystem ->expects ('stub ' )
286
+ ->with ('migration.stub ' )
287
+ ->andReturn ($ this ->stub ('migration.stub ' ));
288
+
289
+ $ now = Carbon::now ();
290
+ Carbon::setTestNow ($ now );
291
+
292
+ $ journey_model_migration = str_replace ('timestamp ' , $ now ->copy ()->subSeconds (2 )->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
293
+ $ diary_model_migration = str_replace ('timestamp ' , $ now ->copy ()->subSecond ()->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diaries_table.php ' );
294
+ $ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diary_journey_table.php ' );
295
+
296
+ $ this ->filesystem ->expects ('exists ' )->times (3 )->andReturn (false );
297
+
298
+ $ this ->filesystem ->expects ('put ' )
299
+ ->with ($ journey_model_migration , $ this ->fixture ('migrations/belongs-to-many-key-constraints-using-uuid-columns-journey-model.php ' ));
300
+ $ this ->filesystem ->expects ('put ' )
301
+ ->with ($ diary_model_migration , $ this ->fixture ('migrations/belongs-to-many-key-constraints-using-uuid-columns-diary-model.php ' ));
302
+
303
+ $ this ->filesystem ->expects ('put ' )
304
+ ->with ($ pivot_migration , $ this ->fixture ('migrations/belongs-to-many-pivot-key-constraints-using-uuid-columns.php ' ));
305
+
306
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/belongs-to-many-using-uuids.yaml ' ));
307
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
308
+
309
+ $ this ->assertEquals (['created ' => [$ journey_model_migration , $ diary_model_migration , $ pivot_migration ]], $ this ->subject ->output ($ tree ));
310
+ }
311
+
248
312
#[Test]
249
313
public function output_also_creates_constraints_for_pivot_table_migration (): void
250
314
{
0 commit comments