diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-04 21:11:25 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-04 21:11:25 +0200 |
| commit | a0a495d804319c3f7ad179baba7b87b41f1dc1f3 (patch) | |
| tree | 2ab56641c32ca606b2423a1dfff1649c2208b1e3 /doc/CUTOVER_2026.md | |
| parent | ac01156d00b24d14225c8e75979fb59bba69640d (diff) | |
Rework the README/INSTALL documents and provide a bootstrap script (untested ;)
Diffstat (limited to 'doc/CUTOVER_2026.md')
| -rw-r--r-- | doc/CUTOVER_2026.md | 348 |
1 files changed, 348 insertions, 0 deletions
diff --git a/doc/CUTOVER_2026.md b/doc/CUTOVER_2026.md new file mode 100644 index 00000000..2a6cb22a --- /dev/null +++ b/doc/CUTOVER_2026.md | |||
| @@ -0,0 +1,348 @@ | |||
| 1 | # Rails 2 to Rails 8 cutover, June 2026 | ||
| 2 | |||
| 3 | A historical record of one migration onto a fresh FreeBSD jail. NOT an | ||
| 4 | installation guide and no longer maintained: branch names, Ruby and | ||
| 5 | gemset versions, migration stamps and expected test counts are all | ||
| 6 | stale. See INSTALL.md for setting the project up. | ||
| 7 | |||
| 8 | ## CCCMS Installation Guide | ||
| 9 | |||
| 10 | This document covers the non-obvious steps required to install the CCCMS | ||
| 11 | stack on a fresh FreeBSD jail. It assumes a FreeBSD 14.x base jail with | ||
| 12 | network access and a working pkg repository. | ||
| 13 | |||
| 14 | ## 1. Install packages | ||
| 15 | |||
| 16 | ```sh | ||
| 17 | pkg install gmake pkgconf curl gnupg git autoconf automake libtool bash \ | ||
| 18 | readline libyaml libffi gdbm libxml2 libxslt libical \ | ||
| 19 | postgresql16-server postgresql16-client \ | ||
| 20 | ImageMagick7-nox11 node vim | ||
| 21 | ``` | ||
| 22 | |||
| 23 | Note: the package is `ImageMagick7-nox11`, not `ImageMagick-nox11`. The | ||
| 24 | nox11 variant avoids pulling in the entire X11 dependency chain. | ||
| 25 | |||
| 26 | ## 2. Enable sysvipc for the jail | ||
| 27 | |||
| 28 | PostgreSQL uses System V shared memory for inter-process communication. | ||
| 29 | On the host, the jail must have sysvipc enabled. In `/etc/jail.conf` or | ||
| 30 | the jail's ezjail configuration: | ||
| 31 | |||
| 32 | `allow.sysvipc = 1;` | ||
| 33 | |||
| 34 | Restart the jail after making this change. Without it, PostgreSQL will | ||
| 35 | fail to start with a shared memory error. | ||
| 36 | |||
| 37 | ## 3. Enable and initialise PostgreSQL | ||
| 38 | |||
| 39 | ```sh | ||
| 40 | # Enable PostgreSQL in rc.conf | ||
| 41 | echo 'postgresql_enable="YES"' >> /etc/rc.conf | ||
| 42 | |||
| 43 | # Initialise the database cluster | ||
| 44 | service postgresql initdb | ||
| 45 | |||
| 46 | # Start PostgreSQL | ||
| 47 | service postgresql start | ||
| 48 | ``` | ||
| 49 | |||
| 50 | ## 4. Create database roles and set permissions | ||
| 51 | |||
| 52 | ```sh | ||
| 53 | psql -U postgres postgres | ||
| 54 | ``` | ||
| 55 | |||
| 56 | ```sql | ||
| 57 | CREATE ROLE rails WITH LOGIN PASSWORD 'your-password-here'; | ||
| 58 | ALTER ROLE rails CREATEDB; | ||
| 59 | ``` | ||
| 60 | |||
| 61 | `CREATEDB` is required for the Rails test suite to create and drop the | ||
| 62 | test database between runs. | ||
| 63 | |||
| 64 | ## 5. Create databases | ||
| 65 | |||
| 66 | ```sql | ||
| 67 | CREATE DATABASE cccms_production OWNER rails ENCODING 'UTF8' | ||
| 68 | LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0; | ||
| 69 | CREATE DATABASE cccms_dev OWNER rails ENCODING 'UTF8' | ||
| 70 | LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0; | ||
| 71 | CREATE DATABASE psql_test OWNER rails ENCODING 'UTF8' | ||
| 72 | LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0; | ||
| 73 | ``` | ||
| 74 | |||
| 75 | `TEMPLATE template0` is required when specifying a non-default locale. | ||
| 76 | |||
| 77 | ## 6. Restore the database dump (or start empty) | ||
| 78 | |||
| 79 | If restoring from a pg_dump: | ||
| 80 | |||
| 81 | ```sh | ||
| 82 | pg_restore -U postgres -d cccms_production \ | ||
| 83 | --no-owner --no-acl /path/to/cccms_production.dump | ||
| 84 | |||
| 85 | pg_restore -U postgres -d cccms_dev \ | ||
| 86 | --no-owner --no-acl /path/to/cccms_production.dump | ||
| 87 | ``` | ||
| 88 | |||
| 89 | Expected harmless warnings: | ||
| 90 | - `schema "public" already exists` — benign, ignore | ||
| 91 | - `array_accum aggregate` failure — dead code, ignore | ||
| 92 | |||
| 93 | Transfer ownership to the rails user (REASSIGN OWNED does not work on | ||
| 94 | PostgreSQL 15+ due to system object protection): | ||
| 95 | |||
| 96 | ```sh | ||
| 97 | psql -U postgres cccms_production | ||
| 98 | ``` | ||
| 99 | |||
| 100 | ```sql | ||
| 101 | DO $$ | ||
| 102 | DECLARE | ||
| 103 | obj RECORD; | ||
| 104 | BEGIN | ||
| 105 | FOR obj IN | ||
| 106 | SELECT tablename FROM pg_tables WHERE schemaname = 'public' | ||
| 107 | LOOP | ||
| 108 | EXECUTE 'ALTER TABLE public.' || quote_ident(obj.tablename) || | ||
| 109 | ' OWNER TO rails'; | ||
| 110 | END LOOP; | ||
| 111 | FOR obj IN | ||
| 112 | SELECT sequence_name FROM information_schema.sequences | ||
| 113 | WHERE sequence_schema = 'public' | ||
| 114 | LOOP | ||
| 115 | EXECUTE 'ALTER SEQUENCE public.' || quote_ident(obj.sequence_name) || | ||
| 116 | ' OWNER TO rails'; | ||
| 117 | END LOOP; | ||
| 118 | FOR obj IN | ||
| 119 | SELECT viewname FROM pg_views WHERE schemaname = 'public' | ||
| 120 | LOOP | ||
| 121 | EXECUTE 'ALTER VIEW public.' || quote_ident(obj.viewname) || | ||
| 122 | ' OWNER TO rails'; | ||
| 123 | END LOOP; | ||
| 124 | END $$; | ||
| 125 | |||
| 126 | ALTER SCHEMA public OWNER TO rails; | ||
| 127 | ``` | ||
| 128 | |||
| 129 | Repeat for `cccms_dev`. | ||
| 130 | |||
| 131 | ## 7. Clone the repository | ||
| 132 | |||
| 133 | ```sh | ||
| 134 | cd /usr/local/www | ||
| 135 | git clone https://github.com/erdgeist/cccms.git | ||
| 136 | cd cccms | ||
| 137 | git checkout rails-upgrade | ||
| 138 | ``` | ||
| 139 | |||
| 140 | ## 8. Copy assets (optional but recommended) | ||
| 141 | |||
| 142 | The `public/system/uploads/` directory contains all uploaded files | ||
| 143 | referenced by the database. Without it, images and attachments will be | ||
| 144 | missing throughout the site. | ||
| 145 | |||
| 146 | ```sh | ||
| 147 | # On the source system: | ||
| 148 | tar -czf /tmp/cccms_uploads.tar.gz -C /usr/local/www cccms/public/system | ||
| 149 | |||
| 150 | # On the new system: | ||
| 151 | tar -xzf /path/to/cccms_uploads.tar.gz -C /usr/local/www | ||
| 152 | ``` | ||
| 153 | |||
| 154 | ## 9. Copy gitignored config files | ||
| 155 | |||
| 156 | These files are not in the repository and must be copied or created: | ||
| 157 | |||
| 158 | ```sh | ||
| 159 | # Required: | ||
| 160 | config/database.yml | ||
| 161 | config/initializers/secret_token.rb | ||
| 162 | |||
| 163 | # If used: | ||
| 164 | config/initializers/exception_notification.rb | ||
| 165 | /usr/local/etc/unicorn.rb | ||
| 166 | ``` | ||
| 167 | |||
| 168 | `database.yml` template: | ||
| 169 | |||
| 170 | ```yaml | ||
| 171 | development: | ||
| 172 | adapter: postgresql | ||
| 173 | encoding: unicode | ||
| 174 | database: cccms_dev | ||
| 175 | pool: 5 | ||
| 176 | username: rails | ||
| 177 | password: your-password-here | ||
| 178 | |||
| 179 | test: | ||
| 180 | adapter: postgresql | ||
| 181 | encoding: UTF8 | ||
| 182 | database: psql_test | ||
| 183 | username: rails | ||
| 184 | password: | ||
| 185 | |||
| 186 | production: | ||
| 187 | adapter: postgresql | ||
| 188 | encoding: unicode | ||
| 189 | database: cccms_production | ||
| 190 | pool: 5 | ||
| 191 | username: rails | ||
| 192 | password: your-password-here | ||
| 193 | ``` | ||
| 194 | |||
| 195 | ## 10. Install rvm | ||
| 196 | |||
| 197 | rvm 1.29.12 is the latest formal release as of mid-2026. Download and | ||
| 198 | verify before installing: | ||
| 199 | |||
| 200 | ```sh | ||
| 201 | curl -L https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz \ | ||
| 202 | -o /tmp/rvm-1.29.12.tar.gz | ||
| 203 | curl -L https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc \ | ||
| 204 | -o /tmp/rvm-1.29.12.tar.gz.asc | ||
| 205 | |||
| 206 | gpg --keyserver hkps://keys.openpgp.org \ | ||
| 207 | --recv-keys 7D2BAF1CF37B13E2069D6956105BD0E739499BDB | ||
| 208 | |||
| 209 | gpg --verify /tmp/rvm-1.29.12.tar.gz.asc /tmp/rvm-1.29.12.tar.gz | ||
| 210 | ``` | ||
| 211 | |||
| 212 | If verification passes: | ||
| 213 | |||
| 214 | ```sh | ||
| 215 | tar -xzf /tmp/rvm-1.29.12.tar.gz -C /tmp | ||
| 216 | bash /tmp/rvm-1.29.12/install --auto-dotfiles | ||
| 217 | source /usr/local/rvm/scripts/rvm | ||
| 218 | ``` | ||
| 219 | |||
| 220 | The installed rvm ships with a stale known-versions list that only goes | ||
| 221 | to Ruby 3.0.0. Update it immediately: | ||
| 222 | |||
| 223 | ```sh | ||
| 224 | curl -L https://raw.githubusercontent.com/rvm/rvm/master/config/known \ | ||
| 225 | -o /usr/local/rvm/config/known | ||
| 226 | rvm list known | grep '^\[ruby-\]3\.' | ||
| 227 | ``` | ||
| 228 | |||
| 229 | Should now show Ruby 3.2.x and later. | ||
| 230 | |||
| 231 | ## 11. Install Ruby and create gemset | ||
| 232 | |||
| 233 | ```sh | ||
| 234 | source /usr/local/rvm/scripts/rvm | ||
| 235 | rvm install 3.2.11 --autolibs=read-only --with-opt-dir=/usr/local | ||
| 236 | rvm use 3.2.11 | ||
| 237 | rvm gemset create rails7-upgrade | ||
| 238 | rvm use 3.2.11@rails7-upgrade | ||
| 239 | ``` | ||
| 240 | |||
| 241 | The `.ruby-version` and `.ruby-gemset` files in the project root will | ||
| 242 | cause rvm to switch automatically when entering the project directory. | ||
| 243 | |||
| 244 | ## 12. Install bundler and gems | ||
| 245 | |||
| 246 | ```sh | ||
| 247 | gem install bundler | ||
| 248 | cd /usr/local/www/cccms | ||
| 249 | export MAKE=gmake | ||
| 250 | bundle install 2>&1 | tee /tmp/bundle_install.log | ||
| 251 | ``` | ||
| 252 | |||
| 253 | `MAKE=gmake` is required because FreeBSD's native make (BSD make) uses | ||
| 254 | different `-j` syntax than native gems expect. Without it, several native | ||
| 255 | gem compilations will fail. | ||
| 256 | |||
| 257 | ## 13. Run migrations | ||
| 258 | |||
| 259 | ```sh | ||
| 260 | bundle exec rails db:migrate | ||
| 261 | ``` | ||
| 262 | |||
| 263 | If restoring an existing database, first insert fake migration versions | ||
| 264 | to prevent re-running migrations that were applied to the old schema: | ||
| 265 | |||
| 266 | ```sql | ||
| 267 | INSERT INTO schema_migrations (version) VALUES | ||
| 268 | ('20260624035149'), ('20260624035150'), ('20260624035151'), | ||
| 269 | ('20260624035152'), ('20260624035153'), | ||
| 270 | ('20260625031409') | ||
| 271 | ON CONFLICT DO NOTHING; | ||
| 272 | ``` | ||
| 273 | |||
| 274 | Then run `db:migrate` to apply only new migrations. | ||
| 275 | |||
| 276 | To enable full-text search (requires PostgreSQL 10+ with plpgsql): | ||
| 277 | |||
| 278 | ```sh | ||
| 279 | mv doc/20260626025705_add_search_vector_to_page_translations.rb.pending \ | ||
| 280 | db/migrate/20260626025705_add_search_vector_to_page_translations.rb | ||
| 281 | bundle exec rails db:migrate | ||
| 282 | ``` | ||
| 283 | |||
| 284 | ## 14. Compile admin assets | ||
| 285 | |||
| 286 | ```sh | ||
| 287 | bundle exec rails assets:precompile | ||
| 288 | ``` | ||
| 289 | |||
| 290 | This compiles the admin JavaScript bundle (jQuery, jQuery UI, hotkeys) | ||
| 291 | into `public/assets/`. Required for the admin interface to work. Must be | ||
| 292 | re-run after any changes to `app/assets/javascripts/admin_bundle.js`. | ||
| 293 | |||
| 294 | ## 15. Run tests (optional but recommended) | ||
| 295 | |||
| 296 | ```sh | ||
| 297 | bundle exec rake test | ||
| 298 | ``` | ||
| 299 | |||
| 300 | Expected result: 129 runs, ~339 assertions, 3 failures, 0 errors. | ||
| 301 | The 3 failures are pre-existing and documented in the handover document. | ||
| 302 | |||
| 303 | ## 16. Start the server | ||
| 304 | |||
| 305 | Development: | ||
| 306 | |||
| 307 | ```sh | ||
| 308 | bundle exec rails server -p 3000 -b 0.0.0.0 -e development | ||
| 309 | ``` | ||
| 310 | |||
| 311 | Note: `-b 0.0.0.0` is required — `localhost` does not resolve inside | ||
| 312 | a FreeBSD jail. | ||
| 313 | |||
| 314 | Production (unicorn): | ||
| 315 | |||
| 316 | ```sh | ||
| 317 | /usr/local/rvm/gems/ruby-3.2.11@rails7-upgrade/wrappers/unicorn \ | ||
| 318 | -c /usr/local/etc/unicorn.rb -E production -D | ||
| 319 | ``` | ||
| 320 | |||
| 321 | The rc.d script at `/etc/rc.d/cccms` needs updating from `unicorn_rails` | ||
| 322 | to `unicorn` before use — see the handover document for details. | ||
| 323 | |||
| 324 | ## Known Gotchas | ||
| 325 | |||
| 326 | **sysvipc:** PostgreSQL will fail silently or with a cryptic error if | ||
| 327 | sysvipc is not enabled for the jail. Enable it on the host before starting | ||
| 328 | PostgreSQL. | ||
| 329 | |||
| 330 | **MAKE=gmake:** Native gem compilation fails without this. Set it before | ||
| 331 | every `bundle install` or add to your shell profile. | ||
| 332 | |||
| 333 | **rvm known versions:** rvm 1.29.12 ships with a stale `config/known` that | ||
| 334 | only lists Ruby up to 3.0.0. Always update from master after installing rvm. | ||
| 335 | |||
| 336 | **ImageMagick 7:** The `convert` command is deprecated; use `magick convert`. | ||
| 337 | The `file_attachment.rb` concern needs updating before production use. | ||
| 338 | |||
| 339 | **pg_hba.conf:** The default FreeBSD PostgreSQL configuration uses `trust` | ||
| 340 | for local Unix socket connections, which is sufficient for the application. | ||
| 341 | No changes needed unless TCP connections are required. | ||
| 342 | |||
| 343 | **assets:precompile:** Must be run after checkout and after any changes to | ||
| 344 | admin JavaScript. The compiled files in `public/assets/` are gitignored. | ||
| 345 | |||
| 346 | **chaos_calendar include path:** On FreeBSD 14.x with libical 3.0.20+, | ||
| 347 | the include path is `<libical/ical.h>` not `<ical.h>`. This is already | ||
| 348 | fixed in the `erdgeist-ruby1.9` branch. | ||
