Skip to content

Commit 5c0ddb6

Browse files
committed
For dev convenience, added a DB-reset script and some basic fixtures. Also attempt to deal with git-ignoring 'static'
1 parent add5695 commit 5c0ddb6

4 files changed

Lines changed: 64 additions & 4 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ contrib/vagrant/nodes/
6464
# See Vagrantfile.local.example
6565
logs
6666
venv
67+
static
68+
!static/

api/fixtures/deis_dev.sql

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--
2+
-- PostgreSQL database dump
3+
--
4+
5+
SET statement_timeout = 0;
6+
SET client_encoding = 'UTF8';
7+
SET standard_conforming_strings = on;
8+
SET check_function_bodies = false;
9+
SET client_min_messages = warning;
10+
11+
SET search_path = public, pg_catalog;
12+
13+
--
14+
-- Data for Name: auth_user; Type: TABLE DATA; Schema: public; Owner: deis
15+
--
16+
17+
COPY auth_user (id, password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined) FROM stdin;
18+
2 pbkdf2_sha256$12000$AMAIZeSq7IBP$6F8fYzjn7z1BBuBBDJfAA84eTW+SNknv6aqiYdc8OyY= 2014-01-20 07:58:08.834168-07 t dev dev@dev.com t t 2014-01-20 07:58:08.07811-07
19+
\.
20+
21+
22+
--
23+
-- Data for Name: api_formation; Type: TABLE DATA; Schema: public; Owner: deis
24+
--
25+
26+
COPY api_formation (uuid, created, updated, owner_id, id, domain, nodes) FROM stdin;
27+
8edebda0-8a73-4de7-a32d-0760daa9563e 2014-01-20 07:58:10.749391-07 2014-01-20 07:58:10.74948-07 2 dev \N {}
28+
\.
29+
30+
31+
--
32+
-- Name: auth_user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: deis
33+
--
34+
35+
SELECT pg_catalog.setval('auth_user_id_seq', 2, true);
36+
37+
38+
--
39+
-- PostgreSQL database dump complete
40+
--
41+

contrib/vagrant/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ the one from Pip.
8989
* Get a list of commands with; `./manage.py help`.
9090

9191
* To reset the DB:
92-
* On the VM run `sudo su postgres -c 'dropdb deis && createdb --encoding=utf8 --template=template0 deis'`
93-
* When you restart the server with `sudo service deis-server restart` Django will reinstall the DB.
94-
* You'll need to reupdate the Django's Site Object
95-
`sudo su deis -c "psql deis -c \"UPDATE django_site SET domain = 'deis-controller.local', name = 'deis-controller.local' WHERE id = 1 \""`
92+
* There is a script at `contrib/vagrant/util/reset-db.sh` that resets the DB and installs some basic fixtures.
93+
* It installs a formation named 'dev' and a super user with username 'dev' and password 'dev'.
9694

9795
* This is useful for uploading your own local version of the cookbooks, rather than the Github versions:
9896
* `knife cookbook upload deis --cookbook-path [deis-cookbook path] --force`

contrib/vagrant/util/reset-db.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash -e
2+
3+
# NB. Command for exporting fixtures
4+
# pg_dump --data-only --table=api_formations --table=auth_user deis > api/fixtures/deis_dev.sql
5+
# And then edit the resulting SQL to remove the default anonymous user
6+
7+
if [[ $EUID -ne 0 ]]; then
8+
echo "This script must be run as root" 1>&2
9+
exit 1
10+
fi
11+
12+
echo "Dropping and recreating Deis database..."
13+
su postgres -c 'dropdb deis && createdb --encoding=utf8 --template=template0 deis'
14+
echo "Running South migrations..."
15+
su deis -c '/opt/deis/controller/venv/bin/python /opt/deis/controller/manage.py syncdb --migrate --noinput'
16+
echo "Updating the Django site object..."
17+
su deis -c "psql deis -c \"UPDATE django_site SET domain = 'deis-controller.local', name = 'deis-controller.local' WHERE id = 1 \""
18+
echo "Importing fixtures for formation and super user..."
19+
su deis -c 'psql deis < /opt/deis/controller/api/fixtures/deis_dev.sql'

0 commit comments

Comments
 (0)