ruby_cms 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f85aad882d87190c071391e338a48b7f327af01400b5bc38fb71d64d014cf6a
4
- data.tar.gz: de4bf71cc65a5068f636a0c6a20d7fa2b9dba70d74e768a6997fb94f5a2963e9
3
+ metadata.gz: c0185a46e938019d424aa89089031c85db4426e8c3f82a10b08931a90f61c30f
4
+ data.tar.gz: 48748adc9faa34afbc0f2c2226732576dce5fe90dbc364ce6f95e818dbc27605
5
5
  SHA512:
6
- metadata.gz: 13d628925678ca174113efebf83567afe2624433030bcb6220357ca0c68084cb60f73d589034e9d0d8a6cbb2d966a68979db4c86c5f7609511f3faf12b6bb2ff
7
- data.tar.gz: eaa696efdaeb63702871a4a6cb41147bd6916d4fe203cbe9518079a99f6fa08120914e37704ff6a883acd1f9b713498461c3a1fa52d29ce0471ddb593620fa00
6
+ metadata.gz: 6498bde78bde18f65d54315fc4ebdddf3791a8fc3c5313d4960e704142453787b4fa9807b76a87e5f4ffa5f71550b1d36d3a122fbcb12bfa899f02c54d96f940
7
+ data.tar.gz: 7f47ce07cc7a7152464a10d9d24500d8ea29d209c50ac39a2dd6114c9fc8cb76f67061e3bc4443027e249b4c24778e448d39f3b711d8a47654346776db25b14c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.1] - 2026-06-29
4
+
5
+ ### Fixed
6
+
7
+ - SQLite compatibility: new `RubyCms::MigrationHelpers.json_column` picks `jsonb` on PostgreSQL and `json` elsewhere; all gem migrations (`content_block_versions`, `audit_log_entries`, `media_assets`, `command_runs`) use it
8
+ - `media_assets` GIN index on `tags` is now created only on PostgreSQL
9
+ - `MigrationReconciler` stamps via adapter-agnostic raw SQL against the real `schema_migrations` table instead of the `ActiveRecord::SchemaMigration` model
10
+ - Installer reconciles via the `ruby_cms:reconcile_migrations` rake task; CLI shows a "Reconciling migrations" step label
11
+
3
12
  ## [1.1.0] - 2026-06-29
4
13
 
5
14
  ### Added
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ruby_cms/migration_helpers"
4
+
3
5
  class CreateContentBlockVersions < ActiveRecord::Migration[7.1]
4
6
  def change
5
7
  create_table :content_block_versions, if_not_exists: true do |t|
@@ -12,7 +14,7 @@ class CreateContentBlockVersions < ActiveRecord::Migration[7.1]
12
14
  t.string :content_type, null: false
13
15
  t.boolean :published, null: false, default: true
14
16
  t.string :event, null: false, default: "update"
15
- t.jsonb :metadata, default: {}
17
+ RubyCms::MigrationHelpers.json_column(t, :metadata, default: {})
16
18
  t.datetime :created_at, null: false
17
19
  end
18
20
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ruby_cms/migration_helpers"
4
+
3
5
  class CreateAuditLogEntries < ActiveRecord::Migration[8.0]
4
6
  def change
5
7
  create_table :audit_log_entries, if_not_exists: true do |t|
@@ -12,7 +14,7 @@ class CreateAuditLogEntries < ActiveRecord::Migration[8.0]
12
14
  t.string :summary, limit: 500
13
15
  t.string :ip, limit: 64
14
16
  t.string :user_agent, limit: 500
15
- t.jsonb :metadata, null: false, default: {}
17
+ RubyCms::MigrationHelpers.json_column(t, :metadata, null: false, default: {})
16
18
  t.datetime :created_at, null: false
17
19
  end
18
20
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ruby_cms/migration_helpers"
4
+
3
5
  class CreateMediaAssets < ActiveRecord::Migration[8.1]
4
6
  def change
5
7
  create_table :media_assets, if_not_exists: true do |t|
@@ -11,7 +13,7 @@ class CreateMediaAssets < ActiveRecord::Migration[8.1]
11
13
  t.integer :width
12
14
  t.integer :height
13
15
  t.references :uploaded_by, foreign_key: { to_table: :users }, type: :bigint
14
- t.jsonb :tags, default: []
16
+ RubyCms::MigrationHelpers.json_column(t, :tags, default: [])
15
17
  t.string :tone
16
18
  t.integer :used_count, default: 0
17
19
  t.timestamps
@@ -20,6 +22,8 @@ class CreateMediaAssets < ActiveRecord::Migration[8.1]
20
22
  add_index :media_assets, :folder, if_not_exists: true
21
23
  add_index :media_assets, :kind, if_not_exists: true
22
24
  add_index :media_assets, :created_at, if_not_exists: true
23
- add_index :media_assets, :tags, using: :gin, if_not_exists: true
25
+ if connection.adapter_name.match?(/postgres/i)
26
+ add_index :media_assets, :tags, using: :gin, if_not_exists: true
27
+ end
24
28
  end
25
29
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ruby_cms/migration_helpers"
4
+
3
5
  class CreateCommandRuns < ActiveRecord::Migration[8.1]
4
6
  def change
5
7
  create_table :command_runs, if_not_exists: true do |t|
@@ -8,7 +10,7 @@ class CreateCommandRuns < ActiveRecord::Migration[8.1]
8
10
  t.integer :duration_ms, null: false, default: 0
9
11
  t.text :output
10
12
  t.text :error_message
11
- t.jsonb :params_used, null: false, default: {}
13
+ RubyCms::MigrationHelpers.json_column(t, :params_used, null: false, default: {})
12
14
  t.references :ran_by, foreign_key: { to_table: :users }, type: :bigint
13
15
  t.string :ran_by_label
14
16
  t.datetime :started_at, null: false
data/lib/ruby_cms/cli.rb CHANGED
@@ -151,6 +151,7 @@ module RubyCms
151
151
  "noticed:install:migrations" => "Installing notifications",
152
152
  "db:migrate" => "Running migrations",
153
153
  "seed_permissions" => "Seeding permissions",
154
+ "reconcile_migrations" => "Reconciling migrations",
154
155
  "tailwindcss:build" => "Building styles"
155
156
  }.freeze
156
157
 
@@ -145,10 +145,7 @@ module RubyCms
145
145
  end
146
146
 
147
147
  def reconcile_migrations
148
- @shell.run(
149
- 'bin/rails runner "require \"ruby_cms/migration_reconciler\"; ' \
150
- 'RubyCms::MigrationReconciler.new(app_root: Rails.root).reconcile!"'
151
- )
148
+ @shell.run("bin/rails ruby_cms:reconcile_migrations")
152
149
  end
153
150
 
154
151
  # Run a command the rest of the install depends on; abort with a clear message
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyCms
4
+ # Shared helpers for CMS migrations (json on SQLite, jsonb on PostgreSQL).
5
+ module MigrationHelpers
6
+ module_function
7
+
8
+ def json_column(table, name, **options)
9
+ if table.respond_to?(:jsonb)
10
+ table.jsonb(name, **options)
11
+ else
12
+ table.json(name, **options)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -22,26 +22,42 @@ module RubyCms
22
22
  conn = ActiveRecord::Base.connection
23
23
  return unless conn.table_exists?(:noticed_events)
24
24
 
25
- stamp_pending!(@migrate_dir.glob(NOTICED_PATTERNS[0]))
25
+ stamp_pending!(conn, @migrate_dir.glob(NOTICED_PATTERNS[0]))
26
26
  return unless conn.column_exists?(:noticed_events, :notifications_count)
27
27
 
28
- stamp_pending!(@migrate_dir.glob(NOTICED_PATTERNS[1]))
28
+ stamp_pending!(conn, @migrate_dir.glob(NOTICED_PATTERNS[1]))
29
29
  end
30
30
 
31
31
  private
32
32
 
33
- def stamp_pending!(paths)
33
+ def stamp_pending!(conn, paths)
34
34
  paths.each do |path|
35
35
  version = path.basename.to_s[/\A(\d+)_/, 1]
36
36
  next unless version
37
- next if schema_migration.where(version: version).exists?
37
+ next if migration_recorded?(conn, version)
38
38
 
39
- schema_migration.create!(version: version)
39
+ conn.execute(
40
+ ActiveRecord::Base.sanitize_sql_array(
41
+ ["INSERT INTO #{schema_migrations_table(conn)} (version) VALUES (?)", version]
42
+ )
43
+ )
40
44
  end
41
45
  end
42
46
 
43
- def schema_migration
44
- ActiveRecord::SchemaMigration
47
+ def migration_recorded?(conn, version)
48
+ conn.select_value(
49
+ ActiveRecord::Base.sanitize_sql_array(
50
+ ["SELECT 1 FROM #{schema_migrations_table(conn)} WHERE version = ? LIMIT 1", version]
51
+ )
52
+ )
53
+ end
54
+
55
+ def schema_migrations_table(conn)
56
+ if conn.respond_to?(:schema_migration) && conn.schema_migration.respond_to?(:table_name)
57
+ conn.schema_migration.table_name
58
+ else
59
+ "schema_migrations"
60
+ end
45
61
  end
46
62
  end
47
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyCms
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codebyjob
@@ -681,6 +681,7 @@ files:
681
681
  - lib/ruby_cms/lockfile.rb
682
682
  - lib/ruby_cms/manifest.rb
683
683
  - lib/ruby_cms/manifest_data.rb
684
+ - lib/ruby_cms/migration_helpers.rb
684
685
  - lib/ruby_cms/migration_installer.rb
685
686
  - lib/ruby_cms/migration_reconciler.rb
686
687
  - lib/ruby_cms/nav_assembler.rb