7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
1 |
Sample data
|
7245.1.2
by Guilherme Salgado
rip off section about DB changes from sampledata/README as the instructions for that are in schema/README |
2 |
===========
|
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
3 |
|
4 |
There are two sorts of sample data. One used by developers when playing around |
|
5 |
in http://launchpad.dev and another used by our tests. |
|
6 |
||
7245.1.13
by Guilherme Salgado
A couple changes suggested by Abel/Gavin |
7 |
The sample data used by default in http://launchpad.dev is stored as a SQL |
8 |
file called current-dev.sql, in this same directory. That data is loaded into |
|
9 |
the launchpad_dev DB and you can change it as you like, as its main purpose is |
|
10 |
to aid developers experimenting all features of Launchpad. |
|
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
11 |
|
12 |
Sample data for tests is stored as a SQL file called current.sql, under this |
|
7245.1.13
by Guilherme Salgado
A couple changes suggested by Abel/Gavin |
13 |
same directory. This data is loaded into the launchpad_ftest_template and |
14 |
launchpad_ftest_playground DBs. The former is used by our test runner and the |
|
15 |
latter can be accessed through http://launchpad.dev when you run the web app |
|
16 |
using the test-playground config (i.e. make LPCONFIG=test-playground run), |
|
17 |
so that you can see the world as one of our tests would. |
|
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
18 |
|
19 |
||
20 |
Changing sample data
|
|
21 |
--------------------
|
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
22 |
|
23 |
For non trivial modifications, it is best if you store your sample |
|
24 |
data modifications as a .sql script of INSERT, UPDATE and DELETE statements. |
|
25 |
This is so when you want to commit your changes it is a simple case |
|
26 |
of building a fresh batch of sample data, running your script, and |
|
27 |
making a fresh sampledata snapshot. This ensures that only the changes you |
|
28 |
want to make are made, as well as saving you time if somebody else updates |
|
29 |
the sample data while you are working. |
|
30 |
||
31 |
To update the sample data: |
|
32 |
||
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
33 |
1. Go to the db schema directory:
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
34 |
|
35 |
cd database/schema |
|
36 |
||
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
37 |
2. Make a database with the current sample data:
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
38 |
|
39 |
make |
|
40 |
||
9024.2.4
by Jonathan Lange
Tweak the documentation for editing sample data. |
41 |
3a. Connect to the db, and then do any INSERT or UPDATE commands you need: |
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
42 |
|
43 |
psql -d launchpad_dev -f my_sample_data_mods.sql |
|
44 |
||
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
45 |
If, for any reason, you want to change the sample data used for tests, |
46 |
you should replace launchpad_dev with launchpad_ftest_playground on |
|
47 |
the line above. |
|
48 |
||
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
49 |
If there are errors, fix and start again. |
50 |
||
9024.2.4
by Jonathan Lange
Tweak the documentation for editing sample data. |
51 |
3b. Alternatively, use 'make harness' to connect to the database and use |
52 |
any APIs you need: |
|
53 |
||
54 |
make harness |
|
55 |
||
56 |
Or: |
|
57 |
||
58 |
make harness LPCONFIG=test-playground |
|
59 |
||
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
60 |
4. Make a fresh snapshot of the sample data to newsampledata.sql:
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
61 |
|
62 |
make newsampledata |
|
63 |
||
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
64 |
5. Inspect the new sample data:
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
65 |
|
66 |
cd ../sampledata |
|
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
67 |
diff current-dev.sql newsampledata-dev.sql |
68 |
||
69 |
If your changes are to the sampledata used for tests, the files |
|
70 |
above will be named current.sql and newsampledata.sql instead. |
|
71 |
||
72 |
6. If it passes your sanity checks, just copy it over the existing one:
|
|
73 |
||
74 |
cp newsampledata-dev.sql current-dev.sql |
|
75 |
||
76 |
Or |
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
77 |
|
78 |
cp newsampledata.sql current.sql |
|
79 |
||
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
80 |
if your changes are to the sample data used for tests. |
81 |
||
82 |
7. Ensure the tests still pass:
|
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
83 |
|
84 |
cd ../.. |
|
7245.1.1
by Guilherme Salgado
Make a rough plan, create current-dev.sql (the sample data we will use for playing around) and update the docs for changing sampledata and submitting DB patches. |
85 |
make check # Yeah, yeah, we all know our machines can stand that. |
86 |
||
87 |
8. Commit your changes and submit for review:
|
|
88 |
||
89 |
bzr commit -m 'Added frotz to sampledata..." |
|
90 |
bzr push |
|
91 |
bzr review-submit ... |