@@ -351,7 +351,127 @@ def migrate(x)
351
351
connection . drop_table :more_testings rescue nil
352
352
end
353
353
354
- def test_datetime_doesnt_set_precision_on_change_table
354
+ def test_datetime_doesnt_set_precision_on_change_table_4_2
355
+ create_migration = Class . new ( ActiveRecord ::Migration [ 4.2 ] ) {
356
+ def migrate ( x )
357
+ create_table :more_testings do |t |
358
+ t . datetime :published_at
359
+ end
360
+ end
361
+ } . new
362
+
363
+ change_migration = Class . new ( ActiveRecord ::Migration [ 4.2 ] ) {
364
+ def migrate ( x )
365
+ change_table :more_testings do |t |
366
+ t . datetime :published_at , default : Time . now
367
+ end
368
+ end
369
+ } . new
370
+
371
+ ActiveRecord ::Migrator . new ( :up , [ create_migration , change_migration ] , @schema_migration ) . migrate
372
+
373
+ assert connection . column_exists? ( :more_testings , :published_at , **precision_implicit_default )
374
+ ensure
375
+ connection . drop_table :more_testings rescue nil
376
+ end
377
+
378
+ def test_datetime_doesnt_set_precision_on_change_table_5_0
379
+ create_migration = Class . new ( ActiveRecord ::Migration [ 5.0 ] ) {
380
+ def migrate ( x )
381
+ create_table :more_testings do |t |
382
+ t . datetime :published_at
383
+ end
384
+ end
385
+ } . new
386
+
387
+ change_migration = Class . new ( ActiveRecord ::Migration [ 5.0 ] ) {
388
+ def migrate ( x )
389
+ change_table :more_testings do |t |
390
+ t . datetime :published_at , default : Time . now
391
+ end
392
+ end
393
+ } . new
394
+
395
+ ActiveRecord ::Migrator . new ( :up , [ create_migration , change_migration ] , @schema_migration ) . migrate
396
+
397
+ assert connection . column_exists? ( :more_testings , :published_at , **precision_implicit_default )
398
+ ensure
399
+ connection . drop_table :more_testings rescue nil
400
+ end
401
+
402
+ def test_datetime_doesnt_set_precision_on_change_table_5_1
403
+ create_migration = Class . new ( ActiveRecord ::Migration [ 5.1 ] ) {
404
+ def migrate ( x )
405
+ create_table :more_testings do |t |
406
+ t . datetime :published_at
407
+ end
408
+ end
409
+ } . new
410
+
411
+ change_migration = Class . new ( ActiveRecord ::Migration [ 5.1 ] ) {
412
+ def migrate ( x )
413
+ change_table :more_testings do |t |
414
+ t . datetime :published_at , default : Time . now
415
+ end
416
+ end
417
+ } . new
418
+
419
+ ActiveRecord ::Migrator . new ( :up , [ create_migration , change_migration ] , @schema_migration ) . migrate
420
+
421
+ assert connection . column_exists? ( :more_testings , :published_at , **precision_implicit_default )
422
+ ensure
423
+ connection . drop_table :more_testings rescue nil
424
+ end
425
+
426
+ def test_datetime_doesnt_set_precision_on_change_table_5_2
427
+ create_migration = Class . new ( ActiveRecord ::Migration [ 5.2 ] ) {
428
+ def migrate ( x )
429
+ create_table :more_testings do |t |
430
+ t . datetime :published_at
431
+ end
432
+ end
433
+ } . new
434
+
435
+ change_migration = Class . new ( ActiveRecord ::Migration [ 5.2 ] ) {
436
+ def migrate ( x )
437
+ change_table :more_testings do |t |
438
+ t . datetime :published_at , default : Time . now
439
+ end
440
+ end
441
+ } . new
442
+
443
+ ActiveRecord ::Migrator . new ( :up , [ create_migration , change_migration ] , @schema_migration ) . migrate
444
+
445
+ assert connection . column_exists? ( :more_testings , :published_at , **precision_implicit_default )
446
+ ensure
447
+ connection . drop_table :more_testings rescue nil
448
+ end
449
+
450
+ def test_datetime_doesnt_set_precision_on_change_table_6_0
451
+ create_migration = Class . new ( ActiveRecord ::Migration [ 6.0 ] ) {
452
+ def migrate ( x )
453
+ create_table :more_testings do |t |
454
+ t . datetime :published_at
455
+ end
456
+ end
457
+ } . new
458
+
459
+ change_migration = Class . new ( ActiveRecord ::Migration [ 6.0 ] ) {
460
+ def migrate ( x )
461
+ change_table :more_testings do |t |
462
+ t . datetime :published_at , default : Time . now
463
+ end
464
+ end
465
+ } . new
466
+
467
+ ActiveRecord ::Migrator . new ( :up , [ create_migration , change_migration ] , @schema_migration ) . migrate
468
+
469
+ assert connection . column_exists? ( :more_testings , :published_at , **precision_implicit_default )
470
+ ensure
471
+ connection . drop_table :more_testings rescue nil
472
+ end
473
+
474
+ def test_datetime_doesnt_set_precision_on_change_table_6_1
355
475
create_migration = Class . new ( ActiveRecord ::Migration [ 6.1 ] ) {
356
476
def migrate ( x )
357
477
create_table :more_testings do |t |
0 commit comments