# "stable" branch will not downgrade - fails on db:migrate

**URL:** https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049
**Category:** Self-hosting
**Created:** [1 Gennaio 2018, 12:01pm UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049 "2018-01-01T12:01:58Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Philip\_Colmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/philip_colmer/32/120245_2.png) [@Philip\_Colmer](https://meta.discourse.org/u/Philip_Colmer)
#### Post date: [1 Gennaio 2018, 12:01pm UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/1 "2018-01-01T12:01:58Z")

</div>

I’m trying to set up a new installation of Discourse using the stable branch. The installation completes successfully if I leave app.yml set to “tests-passed”. However, if I change that to stable and rebuild, it fails with:

```
I, [2018-01-01T11:55:35.349654 #13] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
URGENT: type Failed to initialize site default
rake aborted!
ArgumentError: type
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:46:in `eval'
/var/www/discourse/lib/site_setting_extension.rb:221:in `block (2 levels) in refresh!'
/var/www/discourse/lib/site_setting_extension.rb:220:in `map'
/var/www/discourse/lib/site_setting_extension.rb:220:in `block in refresh!'
/var/www/discourse/lib/site_setting_extension.rb:216:in `synchronize'
/var/www/discourse/lib/site_setting_extension.rb:216:in `refresh!'
(eval):6:in `block (2 levels) in run_file'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:46:in `eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:46:in `block (2 levels) in run_file'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:58:in `block in open'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:57:in `open'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:57:in `open'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:36:in `block in run_file'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/transactions.rb:220:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:35:in `run_file'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:26:in `block in run'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:25:in `each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:25:in `run'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/seed-fu-2.3.5/lib/seed-fu.rb:29:in `seed'
/var/www/discourse/lib/tasks/db.rake:8:in `block in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I, [2018-01-01T11:55:39.870156 #13] INFO -- :
== Seed from /var/www/discourse/db/fixtures/001_categories.rb

I, [2018-01-01T11:55:39.870684 #13] INFO -- : Terminating async processes
I, [2018-01-01T11:55:39.870854 #13] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/9.5/bin/postmaster -D /etc/postgresql/9.5/main pid: 44
2018-01-01 11:55:39.871 UTC [44] LOG: received fast shutdown request
2018-01-01 11:55:39.871 UTC [44] LOG: aborting any active transactions
2018-01-01 11:55:39.871 UTC [51] LOG: autovacuum launcher shutting down
I, [2018-01-01T11:55:39.871055 #13] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 159
159:signal-handler (1514807739) Received SIGTERM scheduling shutdown...
2018-01-01 11:55:39.874 UTC [48] LOG: shutting down
2018-01-01 11:55:39.890 UTC [48] LOG: database system is shut down
159:M 01 Jan 11:55:39.894 # User requested shutdown...
159:M 01 Jan 11:55:39.894 * Saving the final RDB snapshot before exiting.
159:M 01 Jan 11:55:39.903 * DB saved on disk
159:M 01 Jan 11:55:39.903 # Redis is now ready to exit, bye bye...

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1508 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
d6f04ca979800ae6938c231f5ec57316431b6cbbe358bd1c843fcc1f94db984a
**FAILED TO BOOTSTRAP** please scroll up and look for earlier error messages, there may be more than one

```

I have tried rebuilding multiple times and I’ve tried completely destroying the installation and starting again but it always fails this way. Changing the branch back to tests-passed allows the rebuild to complete.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [1 Gennaio 2018, 4:16pm UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/2 "2018-01-01T16:16:57Z")

</div>

We don’t support downgrades, so to move to stable you need to start on a brand new install.

---

<div class="post-metadata">

### Author: ![Philip\_Colmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/philip_colmer/32/120245_2.png) [@Philip\_Colmer](https://meta.discourse.org/u/Philip_Colmer)
#### Post date: [2 Gennaio 2018, 7:46am UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/3 "2018-01-02T07:46:08Z")

</div>

I’ve tried it on a brand new install. I deleted the Discourse directory, pruned Docker of any existing images, cloned the git repository, edited app.yml to specify the desired branch and it will not build.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2 Gennaio 2018, 7:46am UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/4 "2018-01-02T07:46:58Z")

</div>

The database storage is outside the container, though, and it looks like you didn’t nuke that?

---

<div class="post-metadata">

### Author: ![Philip\_Colmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/philip_colmer/32/120245_2.png) [@Philip\_Colmer](https://meta.discourse.org/u/Philip_Colmer)
#### Post date: [2 Gennaio 2018, 8:03am UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/5 "2018-01-02T08:03:44Z")

</div>

OK … that is a possibility, although if it isn’t stored within /var/discourse (or whereever the git repository gets cloned), where is it stored since I haven’t specified another path?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2 Gennaio 2018, 10:50am UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/6 "2018-01-02T10:50:16Z")

</div>

It should be in there. Try this:

1. `cd /var/discourse`
2. Stop the container in case it is still running: `sudo ./launcher stop app`
3. Delete the database: `sudo rm -rf shared/standalone/`  
⚠ This step will delete all Discourse-related data!
4. Make sure `app.yml` is on the stable version
5. Run `sudo ./launcher rebuild app` to bootstrap and start the container, which will create a fresh database

The important thing is not to bootstrap any newer version before having selected `stable`, or deleting the `shared` folder in-between – anything else would be a downgrade of a (mostly empty) Discourse database, which is unsupported.

---

<div class="post-metadata">

### Author: ![Philip\_Colmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/philip_colmer/32/120245_2.png) [@Philip\_Colmer](https://meta.discourse.org/u/Philip_Colmer)
#### Post date: [2 Gennaio 2018, 1:39pm UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/7 "2018-01-02T13:39:30Z")

</div>

I’ve realised where I’ve been going wrong … the yml config file references “/var/discourse/shared” but we’re actually using /srv/discourse … so I forgot to update those paths.

Now that I’ve sorted that all out (and properly removed the previously build database), I can correctly set up Discourse on the stable branch.

Sorry for the noise 🙂

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2 Gennaio 2018, 10:16pm UTC](https://meta.discourse.org/t/stable-branch-will-not-downgrade-fails-on-db-migrate/77049/8 "2018-01-02T22:16:47Z")

</div>


