Skip to content

Commit

Permalink
Extensions are ordered since Rails 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jan 17, 2023
1 parent acfc15d commit ec3275d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ config.active_record.dump_schema_after_migration = `git status db/migrate/ --por

## Schema Sanity

Columns and extensions can flip order in `db/schema.rb` when you have multiple developers. One way to prevent this is to [alphabetize them](https://www.pgrs.net/2008/03/12/alphabetize-schema-rb-columns/). Add to the end of your `Rakefile`:
Columns can flip order in `db/schema.rb` when you have multiple developers. One way to prevent this is to [alphabetize them](https://www.pgrs.net/2008/03/12/alphabetize-schema-rb-columns/). Add to the end of your `Rakefile`:

```ruby
task "db:schema:dump": "strong_migrations:alphabetize_columns"
Expand Down
4 changes: 0 additions & 4 deletions lib/strong_migrations/schema_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ def initialize(connection)
def columns(*args, **options)
@connection.columns(*args, **options).sort_by(&:name)
end

def extensions(*args, **options)
@connection.extensions(*args, **options).sort
end
end
end
20 changes: 0 additions & 20 deletions test/alphabetize_schema_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ class AlphabetizeSchemaTest < Minitest::Test
def test_default
schema = dump_schema

if postgresql?
expected_extensions = <<-EOS
enable_extension "btree_gist"
enable_extension "citext"
enable_extension "pgcrypto"
enable_extension "plpgsql"
EOS
assert_match expected_extensions, schema
end

expected_columns = <<-EOS
t.string "name"
t.string "city"
Expand All @@ -27,16 +17,6 @@ def test_enabled
dump_schema
end

if postgresql?
expected_extensions = <<-EOS
enable_extension "btree_gist"
enable_extension "citext"
enable_extension "pgcrypto"
enable_extension "plpgsql"
EOS
assert_match expected_extensions, schema
end

expected_columns = <<-EOS
t.text "description"
t.string "interval"
Expand Down

0 comments on commit ec3275d

Please sign in to comment.