Skip to content

Ridgepole always changes datetime columns after updating ActiveRecord to v7.0 #381

@sankichi92

Description

@sankichi92

I'm sorry. Another problem on datetime columns of ActiveRecord v7.0 remains even after #380.
After updating ActiveRecord from v6.1 to v7.0, the ridgepole -a command changes datetime columns every time.

Steps to reproduce

First, with ActiveRecord v6.1:

# Gemfilie
source "https://rubygems.org"

gem "activerecord", "6.1.4.6"
gem "pg", "1.3.1"
gem "ridgepole", "1.0.3"
# Schemafile
create_table :articles do |t|
  t.string :title
  t.text :content
  t.datetime :published_at
  t.timestamps
end
$ bundle install
$ bundle exec ridgepole -c '{"adapter":"postgresql","database":"blog"}' -a
Apply `Schemafile`
-- create_table("articles")
   -> 0.0088s
$ bundle exec ridgepole -c '{"adapter":"postgresql","database":"blog"}' -a
Apply `Schemafile`
No change

It's OK, but after updating ActiveRecord to v7.0,

diff --git a/Gemfile b/Gemfile
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,5 @@
 source "https://rubygems.org"
 
-gem "activerecord", "6.1.4.6"
+gem "activerecord", "7.0.2.2"
 gem "pg", "1.3.1"
 gem "ridgepole", "1.0.3"
$ bundle update
$ bundle exec ridgepole -c '{"adapter":"postgresql","database":"blog"}' -a
Apply `Schemafile`
-- change_column("articles", "published_at", :datetime, {:null=>true, :default=>nil})
   -> 0.0037s
-- change_column("articles", "created_at", :datetime, {:null=>false, :default=>nil})
   -> 0.0006s
-- change_column("articles", "updated_at", :datetime, {:null=>false, :default=>nil})
   -> 0.0007s
$ bundle exec ridgepole -c '{"adapter":"postgresql","database":"blog"}' -a
Apply `Schemafile`
-- change_column("articles", "published_at", :datetime, {:null=>true, :default=>nil})
   -> 0.0037s
-- change_column("articles", "created_at", :datetime, {:null=>false, :default=>nil})
   -> 0.0006s
-- change_column("articles", "updated_at", :datetime, {:null=>false, :default=>nil})
   -> 0.0007s

change_column for datetime columns runs on every ridgepole -a command.

System configuration

  • PostgreSQL version: 14.1
  • Ruby version: 3.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions