ruby_cms 1.0.2 → 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 +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/generators/ruby_cms/templates/db/migrate/20260328000001_create_content_block_versions.rb +3 -1
- data/lib/generators/ruby_cms/templates/db/migrate/20260525120000_create_audit_log_entries.rb +3 -1
- data/lib/generators/ruby_cms/templates/db/migrate/20260525140000_create_media_assets.rb +6 -2
- data/lib/generators/ruby_cms/templates/db/migrate/20260525160000_create_command_runs.rb +3 -1
- data/lib/generators/ruby_cms/templates/lib/tasks/ruby_cms.rake +6 -0
- data/lib/ruby_cms/cli.rb +1 -0
- data/lib/ruby_cms/installer.rb +27 -1
- data/lib/ruby_cms/migration_helpers.rb +16 -0
- data/lib/ruby_cms/migration_reconciler.rb +63 -0
- data/lib/ruby_cms/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0185a46e938019d424aa89089031c85db4426e8c3f82a10b08931a90f61c30f
|
|
4
|
+
data.tar.gz: 48748adc9faa34afbc0f2c2226732576dce5fe90dbc364ce6f95e818dbc27605
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6498bde78bde18f65d54315fc4ebdddf3791a8fc3c5313d4960e704142453787b4fa9807b76a87e5f4ffa5f71550b1d36d3a122fbcb12bfa899f02c54d96f940
|
|
7
|
+
data.tar.gz: 7f47ce07cc7a7152464a10d9d24500d8ea29d209c50ac39a2dd6114c9fc8cb76f67061e3bc4443027e249b4c24778e448d39f3b711d8a47654346776db25b14c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
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
|
+
|
|
12
|
+
## [1.1.0] - 2026-06-29
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `RubyCms::MigrationReconciler` — partial-install recovery: stamps already-applied `noticed` migrations (`create_noticed_tables`, `add_notifications_count_to_noticed_event`) when their tables/columns already exist, so a re-run with duplicate migration files no longer fails `db:migrate`
|
|
17
|
+
- `rails ruby_cms:reconcile_migrations` rake task to run the reconciler manually
|
|
18
|
+
- Installer skips `noticed:install:migrations` when noticed migrations/tables are already present, and reconciles before `db:migrate`
|
|
19
|
+
|
|
3
20
|
## [1.0.2] - 2026-06-29
|
|
4
21
|
|
|
5
22
|
### Fixed
|
data/lib/generators/ruby_cms/templates/db/migrate/20260328000001_create_content_block_versions.rb
CHANGED
|
@@ -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
|
|
17
|
+
RubyCms::MigrationHelpers.json_column(t, :metadata, default: {})
|
|
16
18
|
t.datetime :created_at, null: false
|
|
17
19
|
end
|
|
18
20
|
|
data/lib/generators/ruby_cms/templates/db/migrate/20260525120000_create_audit_log_entries.rb
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
namespace :ruby_cms do
|
|
4
|
+
desc "Stamp duplicate noticed migrations when tables already exist (partial install recovery)"
|
|
5
|
+
task reconcile_migrations: :environment do
|
|
6
|
+
require "ruby_cms/migration_reconciler"
|
|
7
|
+
RubyCms::MigrationReconciler.new(app_root: Rails.root).reconcile!
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
desc "Create default permissions/settings and grant manage_admin to admin users"
|
|
5
11
|
task seed_permissions: :environment do
|
|
6
12
|
Permission.ensure_defaults!
|
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
|
|
data/lib/ruby_cms/installer.rb
CHANGED
|
@@ -10,6 +10,7 @@ require "ruby_cms/file_installer"
|
|
|
10
10
|
require "ruby_cms/routes_assembler"
|
|
11
11
|
require "ruby_cms/nav_assembler"
|
|
12
12
|
require "ruby_cms/migration_installer"
|
|
13
|
+
require "ruby_cms/migration_reconciler"
|
|
13
14
|
require "ruby_cms/lockfile"
|
|
14
15
|
|
|
15
16
|
module RubyCms
|
|
@@ -114,14 +115,39 @@ module RubyCms
|
|
|
114
115
|
def run_framework_steps(modules)
|
|
115
116
|
steps = BASE_FRAMEWORK_STEPS.dup
|
|
116
117
|
steps.insert(2, AHOY_STEP) if modules.any? {|m| m.key == :analytics }
|
|
117
|
-
steps.each {|cmd|
|
|
118
|
+
steps.each {|cmd| run_framework_step(cmd) }
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def run_framework_step(cmd)
|
|
122
|
+
if cmd.include?("noticed:install:migrations") && noticed_already_setup?
|
|
123
|
+
@shell.ok("notifications", hint: "migrations already present")
|
|
124
|
+
return
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
@shell.run(cmd)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def noticed_already_setup?
|
|
131
|
+
migrate = Pathname(@app_root).join("db/migrate")
|
|
132
|
+
return true if migrate.glob("*create_noticed_tables*.rb").any?
|
|
133
|
+
|
|
134
|
+
return false unless defined?(ActiveRecord::Base)
|
|
135
|
+
|
|
136
|
+
ActiveRecord::Base.connection.table_exists?(:noticed_events)
|
|
137
|
+
rescue StandardError
|
|
138
|
+
false
|
|
118
139
|
end
|
|
119
140
|
|
|
120
141
|
def run_rails_steps
|
|
142
|
+
reconcile_migrations
|
|
121
143
|
run_critical("bin/rails db:migrate")
|
|
122
144
|
@shell.run("bin/rails ruby_cms:seed_permissions")
|
|
123
145
|
end
|
|
124
146
|
|
|
147
|
+
def reconcile_migrations
|
|
148
|
+
@shell.run("bin/rails ruby_cms:reconcile_migrations")
|
|
149
|
+
end
|
|
150
|
+
|
|
125
151
|
# Run a command the rest of the install depends on; abort with a clear message
|
|
126
152
|
# (rather than limping on to a misleading "installed") when it fails.
|
|
127
153
|
def run_critical(cmd)
|
|
@@ -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
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pathname"
|
|
4
|
+
|
|
5
|
+
module RubyCms
|
|
6
|
+
# Stamps pending framework migrations when their schema is already present.
|
|
7
|
+
# Covers partial installs where tables were created under an older timestamp
|
|
8
|
+
# and a re-run added duplicate migration files.
|
|
9
|
+
class MigrationReconciler
|
|
10
|
+
NOTICED_PATTERNS = [
|
|
11
|
+
"*create_noticed_tables*.rb",
|
|
12
|
+
"*add_notifications_count_to_noticed*.rb"
|
|
13
|
+
].freeze
|
|
14
|
+
|
|
15
|
+
def initialize(app_root:)
|
|
16
|
+
@migrate_dir = Pathname(app_root).join("db/migrate")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def reconcile!
|
|
20
|
+
return unless defined?(ActiveRecord::Base)
|
|
21
|
+
|
|
22
|
+
conn = ActiveRecord::Base.connection
|
|
23
|
+
return unless conn.table_exists?(:noticed_events)
|
|
24
|
+
|
|
25
|
+
stamp_pending!(conn, @migrate_dir.glob(NOTICED_PATTERNS[0]))
|
|
26
|
+
return unless conn.column_exists?(:noticed_events, :notifications_count)
|
|
27
|
+
|
|
28
|
+
stamp_pending!(conn, @migrate_dir.glob(NOTICED_PATTERNS[1]))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def stamp_pending!(conn, paths)
|
|
34
|
+
paths.each do |path|
|
|
35
|
+
version = path.basename.to_s[/\A(\d+)_/, 1]
|
|
36
|
+
next unless version
|
|
37
|
+
next if migration_recorded?(conn, version)
|
|
38
|
+
|
|
39
|
+
conn.execute(
|
|
40
|
+
ActiveRecord::Base.sanitize_sql_array(
|
|
41
|
+
["INSERT INTO #{schema_migrations_table(conn)} (version) VALUES (?)", version]
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
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
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/ruby_cms/version.rb
CHANGED
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.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Codebyjob
|
|
@@ -681,7 +681,9 @@ 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
|
|
686
|
+
- lib/ruby_cms/migration_reconciler.rb
|
|
685
687
|
- lib/ruby_cms/nav_assembler.rb
|
|
686
688
|
- lib/ruby_cms/passkey_wiring.rb
|
|
687
689
|
- lib/ruby_cms/path_map.rb
|