ruby_cms 1.0.2 → 1.1.0
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 +8 -0
- data/lib/generators/ruby_cms/templates/lib/tasks/ruby_cms.rake +6 -0
- data/lib/ruby_cms/installer.rb +30 -1
- data/lib/ruby_cms/migration_reconciler.rb +47 -0
- data/lib/ruby_cms/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f85aad882d87190c071391e338a48b7f327af01400b5bc38fb71d64d014cf6a
|
|
4
|
+
data.tar.gz: de4bf71cc65a5068f636a0c6a20d7fa2b9dba70d74e768a6997fb94f5a2963e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13d628925678ca174113efebf83567afe2624433030bcb6220357ca0c68084cb60f73d589034e9d0d8a6cbb2d966a68979db4c86c5f7609511f3faf12b6bb2ff
|
|
7
|
+
data.tar.gz: eaa696efdaeb63702871a4a6cb41147bd6916d4fe203cbe9518079a99f6fa08120914e37704ff6a883acd1f9b713498461c3a1fa52d29ce0471ddb593620fa00
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.1.0] - 2026-06-29
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `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`
|
|
8
|
+
- `rails ruby_cms:reconcile_migrations` rake task to run the reconciler manually
|
|
9
|
+
- Installer skips `noticed:install:migrations` when noticed migrations/tables are already present, and reconciles before `db:migrate`
|
|
10
|
+
|
|
3
11
|
## [1.0.2] - 2026-06-29
|
|
4
12
|
|
|
5
13
|
### Fixed
|
|
@@ -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/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,42 @@ 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(
|
|
149
|
+
'bin/rails runner "require \"ruby_cms/migration_reconciler\"; ' \
|
|
150
|
+
'RubyCms::MigrationReconciler.new(app_root: Rails.root).reconcile!"'
|
|
151
|
+
)
|
|
152
|
+
end
|
|
153
|
+
|
|
125
154
|
# Run a command the rest of the install depends on; abort with a clear message
|
|
126
155
|
# (rather than limping on to a misleading "installed") when it fails.
|
|
127
156
|
def run_critical(cmd)
|
|
@@ -0,0 +1,47 @@
|
|
|
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!(@migrate_dir.glob(NOTICED_PATTERNS[0]))
|
|
26
|
+
return unless conn.column_exists?(:noticed_events, :notifications_count)
|
|
27
|
+
|
|
28
|
+
stamp_pending!(@migrate_dir.glob(NOTICED_PATTERNS[1]))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def stamp_pending!(paths)
|
|
34
|
+
paths.each do |path|
|
|
35
|
+
version = path.basename.to_s[/\A(\d+)_/, 1]
|
|
36
|
+
next unless version
|
|
37
|
+
next if schema_migration.where(version: version).exists?
|
|
38
|
+
|
|
39
|
+
schema_migration.create!(version: version)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def schema_migration
|
|
44
|
+
ActiveRecord::SchemaMigration
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
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.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Codebyjob
|
|
@@ -682,6 +682,7 @@ files:
|
|
|
682
682
|
- lib/ruby_cms/manifest.rb
|
|
683
683
|
- lib/ruby_cms/manifest_data.rb
|
|
684
684
|
- lib/ruby_cms/migration_installer.rb
|
|
685
|
+
- lib/ruby_cms/migration_reconciler.rb
|
|
685
686
|
- lib/ruby_cms/nav_assembler.rb
|
|
686
687
|
- lib/ruby_cms/passkey_wiring.rb
|
|
687
688
|
- lib/ruby_cms/path_map.rb
|