diff options
| -rw-r--r-- | INSTALL.md | 30 |
1 files changed, 19 insertions, 11 deletions
| @@ -109,8 +109,6 @@ ALTER ROLE rails CREATEDB; | |||
| 109 | 109 | ||
| 110 | CREATE DATABASE cccms_dev OWNER rails ENCODING 'UTF8' | 110 | CREATE DATABASE cccms_dev OWNER rails ENCODING 'UTF8' |
| 111 | LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0; | 111 | LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0; |
| 112 | CREATE DATABASE psql_test OWNER rails ENCODING 'UTF8' | ||
| 113 | LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0; | ||
| 114 | ``` | 112 | ``` |
| 115 | 113 | ||
| 116 | `CREATEDB` is needed because the test suite creates and drops its own | 114 | `CREATEDB` is needed because the test suite creates and drops its own |
| @@ -153,18 +151,25 @@ production: | |||
| 153 | Cccms::Application.config.secret_key_base = "<64 hex chars, e.g. from `rails secret`>" | 151 | Cccms::Application.config.secret_key_base = "<64 hex chars, e.g. from `rails secret`>" |
| 154 | ``` | 152 | ``` |
| 155 | 153 | ||
| 156 | ### 4a. Migrate. Never load the schema. | 154 | ### 4a. Load the schema |
| 155 | |||
| 156 | bundle exec rails db:schema:load | ||
| 157 | 157 | ||
| 158 | bundle exec rails db:migrate | 158 | `db/schema.rb` is in the repository and is the authoritative description |
| 159 | of the database. Replaying the migration chain is not a supported route: | ||
| 160 | the oldest migrations predate Rails 4, and some columns were only ever | ||
| 161 | applied by hand. `db:setup` and `db:reset` are safe. | ||
| 159 | 162 | ||
| 160 | Do not run `db:setup` or `db:schema:load`. | 163 | `bundle exec rails db:migrate` is for an existing installation โ see the |
| 164 | deploy sequence in ยง7. | ||
| 161 | 165 | ||
| 162 | `db/schema.rb` is gitignored, and it could not be used even if it were | 166 | The full-text `search_vector` column is maintained by a PostgreSQL trigger, |
| 163 | present: the full-text `search_vector` column is maintained by a PostgreSQL | 167 | which Ruby's schema format cannot express. `db:schema:load` reinstalls it |
| 164 | trigger, and Ruby's schema format cannot express triggers. A schema-loaded | 168 | through a rake hook, and the application reinstalls it at boot, so a fresh |
| 165 | database gets the column and its GIN index with nothing populating them, | 169 | install needs nothing further. A database restored from a dump taken before |
| 166 | and site search then silently returns no results. Migrations are the only | 170 | the trigger existed has rows it cannot repair, because the trigger fires |
| 167 | complete record of the structure. | 171 | only on insert or update. You have to run `pages:backfill_search_vector` |
| 172 | once after such a restore. | ||
| 168 | 173 | ||
| 169 | ## 5. First start | 174 | ## 5. First start |
| 170 | 175 | ||
| @@ -296,6 +301,9 @@ old Ruby. | |||
| 296 | second factor from the shell when every administrator is locked out. | 301 | second factor from the shell when every administrator is locked out. |
| 297 | Deliberately unwitnessed โ there is no actor to attribute a shell | 302 | Deliberately unwitnessed โ there is no actor to attribute a shell |
| 298 | command to. | 303 | command to. |
| 304 | - `pages:backfill_search_vector` fills `search_vector` for rows that have | ||
| 305 | none, and installs the trigger first. Needed after restoring a dump that | ||
| 306 | predates the trigger; harmless otherwise, since it only fills nulls. | ||
| 299 | 307 | ||
| 300 | Logs are in `log/`, gitignored. The action log inside the application at | 308 | Logs are in `log/`, gitignored. The action log inside the application at |
| 301 | `/admin/log` records who changed what; `log/production.log` records | 309 | `/admin/log` records who changed what; `log/production.log` records |
