# What is the latest recommended workflow for local development? (Ubuntu 16.04)

**URL:** https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213
**Category:** Development
**Created:** [October 2, 2017, 10:08pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213 "2017-10-02T22:08:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 2, 2017, 10:08pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/1 "2017-10-02T22:08:26Z")

</div>

I’ve been searching around for the ideal way to develop a discourse site on my laptop (Ubuntu 16.04), but am unsure about the most current best practices. I’m new to Rails and am having trouble figuring out how to setup a local development environment for migration from Drupal, theme development, and plugin development.

Are people generally using their [system’s environment](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727), or [Vagrant](https://blog.discourse.org/2013/04/discourse-as-your-first-rails-app/), or [Docker](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md)?

If I do use my [local environment](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727), what is the general, recommended workflow for syncing code and data with the live, production Docker install?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 2, 2017, 11:13pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/2 "2017-10-02T23:13:48Z")

</div>

Right. You want the [Install Discourse on Ubuntu or Debian for Development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727)

> [@j127](#):
>
> what is the general, recommended workflow for syncing code and data with the live, production Docker install?

I’ve been doing this a year and I mostly don’t know. Here are some things I recommend:

- Always work on a branch
- `git pull upstream master` to re-sync with, uh, upstream

> [@j127](#):
>
> what is the general, recommended workflow for syncing code and data with the live, production Docker install?

Oh. Perhaps this is what you want to know: To sync with production you make plugins. Create a repo for each and symlink it to the plugins directory.

You don’t ever, ever, ever, run your forked code in development.

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 2, 2017, 11:25pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/3 "2017-10-02T23:25:23Z")

</div>

Thanks. Do you have a system for truncating (or dropping and resetting) the databases while working? Right now I’m trying to create a bash script that will do it, but I’m not sure if someone has already solved this kind of problem.

Something like this (unfinished, non-working import script):

```
# Step 1
dropdb discourse_development
dropdb discourse_test
dropdb discourse_test_multisite

# Step 2
echo `whoami` > /tmp/username
sudo su - postgres

# Step 3
# createuser --createdb --superuser -Upostgres $(cat /tmp/username)
# psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD '$PASSWORD';"
psql -c "create database discourse_development owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test_multisite owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -d discourse_development -c "CREATE EXTENSION hstore;"
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test -c "CREATE EXTENSION hstore;"
psql -d discourse_test -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test_multisite -c "CREATE EXTENSION hstore;"
psql -d discourse_test_multisite -c "CREATE EXTENSION pg_trgm;"

# Step 4
exit # postgres user
rails db:migrate

# To create an admin user
rake admin:create

# Run import script
export IMPORT=1
bundle install
RAILS_ENV=development bundle exec ruby script/import_scripts/drupal_7/importer.rb

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 2, 2017, 11:33pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/4 "2017-10-02T23:33:51Z")

</div>

Yeah that bash script is overdoing it a bit.

I use:

```plaintext
#!/bin/bash
set -e

dropdb --if-exists discourse_development
dropdb --if-exists discourse_test
dropdb --if-exists discourse_test_multisite

createdb discourse_development
createdb discourse_test
createdb discourse_test_multisite

redis-cli flushall

bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:migrate

```

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 3, 2017, 4:59am UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/5 "2017-10-03T04:59:52Z")

</div>

Thanks. I’ll try that. 🙂

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 6, 2017, 7:12pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/6 "2017-10-06T19:12:18Z")

</div>

When I save the “about me” field on my local machine (Ubuntu 16.04), the UI says that it has been saved, but when I do a hard refresh of the page, the text is missing. Is there something else that has to be configured to get it to save that to the database?

Rails 5.1.3  
Ruby 2.4.1p111  
Postgres 9.5.9  
Redis server 3.0.6

I can get to redis from `irb`. The local site seems to otherwise mostly work.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 6, 2017, 9:54pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/7 "2017-10-06T21:54:43Z")

</div>

Have you done a `git pull` lately? That bug got fixed a while ago.

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 6, 2017, 10:02pm UTC](https://meta.discourse.org/t/what-is-the-latest-recommended-workflow-for-local-development-ubuntu-16-04/71213/8 "2017-10-06T22:02:35Z")

</div>

Thanks, that was it. 🙂
