Skip to content

Commit 169627f

Browse files
committed
Add formation, provider and flavours to fixtures for more complete seeding
1 parent b7751ab commit 169627f

3 files changed

Lines changed: 59 additions & 19 deletions

File tree

api/fixtures/deis_dev.sql

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,28 @@ SET search_path = public, pg_catalog;
1515
--
1616

1717
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
18+
1 pbkdf2_sha256$12000$18U86XLtKK5h$dV4rNDHjrkWUSPHtCdtwmSUa19OxPjOIKekvTuhs9HI= 2014-01-27 16:30:25.062197-07 t dev dev@dev.com t t 2014-01-27 15:23:49.793007-07
19+
\.
20+
21+
22+
--
23+
-- Data for Name: api_provider; Type: TABLE DATA; Schema: public; Owner: deis
24+
--
25+
26+
COPY api_provider (uuid, created, updated, owner_id, id, type, creds) FROM stdin;
27+
74ae11e2-6080-4817-934b-826d85418ce8 2014-01-27 15:23:49.857304-07 2014-01-27 15:23:49.857328-07 1 static static {}
28+
1ef7e631-79e9-40f5-9702-e2edeab2d066 2014-01-27 15:23:49.861201-07 2014-01-27 15:45:55.145015-07 1 vagrant vagrant {}
29+
\.
30+
31+
32+
--
33+
-- Data for Name: api_flavor; Type: TABLE DATA; Schema: public; Owner: deis
34+
--
35+
36+
COPY api_flavor (uuid, created, updated, owner_id, id, provider_id, params) FROM stdin;
37+
4b65ecb5-3c05-4d9b-9efa-e6b8195099ce 2014-01-27 15:23:52.078972-07 2014-01-27 15:23:52.079003-07 1 vagrant-512 1ef7e631-79e9-40f5-9702-e2edeab2d066 {"memory": "512"}
38+
ebddfd0f-9d16-42b7-9f74-ac9ba4479234 2014-01-27 15:23:52.090896-07 2014-01-27 15:23:52.09093-07 1 vagrant-1024 1ef7e631-79e9-40f5-9702-e2edeab2d066 {"memory": "1024"}
39+
e62447cb-c08d-4e79-b3a4-ad19e52ad616 2014-01-27 15:23:52.092727-07 2014-01-27 15:23:52.092749-07 1 vagrant-2048 1ef7e631-79e9-40f5-9702-e2edeab2d066 {"memory": "2048"}
1940
\.
2041

2142

@@ -24,15 +45,15 @@ COPY auth_user (id, password, last_login, is_superuser, username, first_name, la
2445
--
2546

2647
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 {}
48+
8b196fb8-5774-4512-b3cc-569af8894a6c 2014-01-27 16:32:02.148594-07 2014-01-27 16:32:51.173758-07 1 dev deis-controller.local {}
2849
\.
2950

3051

3152
--
3253
-- Name: auth_user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: deis
3354
--
3455

35-
SELECT pg_catalog.setval('auth_user_id_seq', 2, true);
56+
SELECT pg_catalog.setval('auth_user_id_seq', 1, true);
3657

3758

3859
--
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash -e
2+
3+
# This code is kept in a separate file from `reste-db.sh` for no other reason than to not have to deal
4+
# with the nightmare of double escaping all these commands through `vagrant ssh -c "\\\\\\\\\AGH!"`
5+
6+
# NB. Command for exporting fixtures
7+
# pg_dump --data-only --table=api_formations --table=auth_user --table=api_formation --table=api_provider --table=api_flavor deis > api/fixtures/deis_dev.sql
8+
# And then edit the resulting SQL to remove the default anonymous user
9+
10+
if [[ $EUID -ne 0 ]]; then
11+
echo "This script must be run as root" 1>&2
12+
exit 1
13+
fi
14+
15+
if [[ -z "$VP_HOST" && -z "$VP_USER" ]]; then
16+
echo "VP_HOST and VP_USER must be set"
17+
exit 1
18+
fi
19+
20+
echo "Dropping and recreating Deis database..."
21+
su postgres -c 'dropdb deis && createdb --encoding=utf8 --template=template0 deis'
22+
echo "Running South migrations..."
23+
su deis -c '/opt/deis/controller/venv/bin/python /opt/deis/controller/manage.py syncdb --migrate --noinput'
24+
echo "Updating the Django site object..."
25+
su deis -c "psql deis -c \"UPDATE django_site SET domain = 'deis-controller.local', name = 'deis-controller.local' WHERE id = 1 \""
26+
echo "Importing fixtures for formation and super user..."
27+
su deis -c 'psql deis < /opt/deis/controller/api/fixtures/deis_dev.sql'
28+
echo "Updating vagrant provider details"
29+
su deis -c "psql deis -c \"UPDATE api_provider SET creds = '{\\\"host\\\": \\\"$VP_HOST\\\", \\\"user\\\": \\\"$VP_USER\\\"}' WHERE owner_id = 1 AND type = 'vagrant' \""

contrib/vagrant/util/reset-db.sh

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
#!/bin/bash -e
1+
#/bin/bash -e
22

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
3+
VP_HOST="$(hostname | sed -e 's/^ *//g' -e 's/ *$//g').local"
4+
VP_USER=$(whoami | sed -e 's/^ *//g' -e 's/ *$//g')
65

7-
if [[ $EUID -ne 0 ]]; then
8-
echo "This script must be run as root" 1>&2
9-
exit 1
10-
fi
6+
vagrant ssh -c "sudo VP_HOST=$VP_HOST VP_USER=$VP_USER /opt/deis/controller/contrib/vagrant/util/_controller-reset-db.sh"
117

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'
8+
echo "Logging in user 'dev' with password 'dev'..."
9+
deis login "deis-controller.local" --username=dev --password=dev

0 commit comments

Comments
 (0)