activerecord-pg-format-db-structure 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9eadcc90f7e5d8ec76f9f9494e7049646bf68ed37df502df31a1dc9fae87d2b6
4
- data.tar.gz: bee026074f768393231546155fc52e0d00098cbdec981729a63c5a8d1efeb1c4
3
+ metadata.gz: b1360637cb5c24ce89e734dd5bd544c80cd29e019102e2ea7268e49ab32f6f71
4
+ data.tar.gz: 4ff8913438ffb2991e1c23d734cd8b5b8e0327b1286ca483c5d46e2b422ac7c4
5
5
  SHA512:
6
- metadata.gz: efe9804695f586ea988faa923d5db83483b0a0e1395bdaaaabd3dcdbd93358d96a7c5a0f7688b5bf1512d4e14d49bf68f46c65000c9700cb3ad8ef7d63094908
7
- data.tar.gz: dbdfa7873bd2551f2c1284befbd039c194cc87aaafea7690df8daabc84724c78a06ff3f021940204aa80cdef569566b9c81bfe4cc0aa3aa6180cb7a660e0bb21
6
+ metadata.gz: 5b95bb982ba987fed4a4ae273a337e3d00ee738012bf6c913a81c4d87b2c0e1a3e5ba5caa55bb829df6c242143ffff59e8cecfaab1ab4c517da2232d081023e1
7
+ data.tar.gz: 9e6b856118e64bf1de2370206057082f9e34cfea208c201c71f0cc6cdd52ad6c9bdd1c06b0c0ea5e4183b6a9711a126724a9c6398471d1e5fd32ec3c689a4bd7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2025-02-08
4
+
5
+ - Sort schema migrations inserts
6
+
3
7
  ## [0.1.3] - 2025-02-02
4
8
 
5
9
  - Rework SQL formatting by only adding indentation to deparsed statements
data/README.md CHANGED
@@ -259,6 +259,7 @@ Rails.application.configure do
259
259
 
260
260
  config.activerecord_pg_format_db_structure.transforms = [
261
261
  ActiveRecordPgFormatDbStructure::Transforms::RemoveCommentsOnExtensions,
262
+ ActiveRecordPgFormatDbStructure::Transforms::SortSchemaMigrations,
262
263
  ActiveRecordPgFormatDbStructure::Transforms::InlinePrimaryKeys,
263
264
  # ActiveRecordPgFormatDbStructure::Transforms::InlineForeignKeys,
264
265
  ActiveRecordPgFormatDbStructure::Transforms::InlineSerials,
@@ -293,6 +294,10 @@ Remove unnecessary comment, whitespase and empty lines.
293
294
 
294
295
  Remove COMMENT statement applied to extensions
295
296
 
297
+ ### SortSchemaMigrations
298
+
299
+ Sort schema_migrations inserts to be in chronological order, helps with reducing merge conflicts.
300
+
296
301
  ### InlinePrimaryKeys
297
302
 
298
303
  Inlines primary keys with the table declaration
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module ActiveRecordPgFormatDbStructure
6
+ module Transforms
7
+ # Sort schema migration inserts to reduce merge conflicts
8
+ class SortSchemaMigrations < Base
9
+ def transform!
10
+ raw_statements.each do |raw_statement|
11
+ next unless raw_statement.stmt.to_h in insert_stmt: {
12
+ relation: { relname: "schema_migrations" },
13
+ select_stmt: { select_stmt: { values_lists: _ } }
14
+ }
15
+
16
+ raw_statement.stmt.insert_stmt.select_stmt.select_stmt.values_lists.sort_by! do |list|
17
+ list.list.items.first.a_const.sval.sval
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordPgFormatDbStructure
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -11,6 +11,7 @@ require_relative "activerecord-pg-format-db-structure/transforms/inline_foreign_
11
11
  require_relative "activerecord-pg-format-db-structure/transforms/move_indices_after_create_table"
12
12
  require_relative "activerecord-pg-format-db-structure/transforms/inline_constraints"
13
13
  require_relative "activerecord-pg-format-db-structure/transforms/group_alter_table_statements"
14
+ require_relative "activerecord-pg-format-db-structure/transforms/sort_schema_migrations"
14
15
 
15
16
  module ActiveRecordPgFormatDbStructure
16
17
  DEFAULT_PREPROCESSORS = [
@@ -19,6 +20,7 @@ module ActiveRecordPgFormatDbStructure
19
20
 
20
21
  DEFAULT_TRANSFORMS = [
21
22
  Transforms::RemoveCommentsOnExtensions,
23
+ Transforms::SortSchemaMigrations,
22
24
  Transforms::InlinePrimaryKeys,
23
25
  # Transforms::InlineForeignKeys,
24
26
  Transforms::InlineSerials,
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-pg-format-db-structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jell
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-02 00:00:00.000000000 Z
10
+ date: 2025-02-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: pg_query
@@ -53,6 +53,7 @@ files:
53
53
  - lib/activerecord-pg-format-db-structure/transforms/inline_serials.rb
54
54
  - lib/activerecord-pg-format-db-structure/transforms/move_indices_after_create_table.rb
55
55
  - lib/activerecord-pg-format-db-structure/transforms/remove_comments_on_extensions.rb
56
+ - lib/activerecord-pg-format-db-structure/transforms/sort_schema_migrations.rb
56
57
  - lib/activerecord-pg-format-db-structure/version.rb
57
58
  homepage: https://github.com/ReifyAB/activerecord-pg-format-db-structure
58
59
  licenses: