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