~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
README for Launchpad Sample Data
================================

Overview
--------

For non trivial modifications, it is best if you store your sample
data modifications as a .sql script of INSERT, UPDATE and DELETE statements.
This is so when you want to commit your changes it is a simple case
of building a fresh batch of sample data, running your script, and
making a fresh sampledata snapshot. This ensures that only the changes you
want to make are made, as well as saving you time if somebody else updates
the sample data while you are working.

To update the sample data:

    1.  Go to the db schema directory::

            cd database/schema

    2.  Make a database with the current sample data::

            make

    3.  Connect to the db, and then do any INSERT or UPDATE commands you need::

            psql -d launchpad_dev -f my_sample_data_mods.sql

        If there are errors, fix and start again.

    4.  Make a fresh snapshot of the sample data to newsampledata.sql::

            make newsampledata

    5.  Inspect the new sample data::

            cd ../sampledata
            diff current.sql newsampledata.sql

    6.  If it passes your sanity checks, make it the corrent sample data::

            cp newsampledata.sql current.sql

    7.  Ensure the tests still pass

            cd ../..
            make check

    8.  Commit your changes and merge to Rocketfuel::

            baz commit -s 'Added frotz to sampledata..."
            baz mirror
            arch-submit-merge 'Added frotz to sampledata..."


Database Patches
----------------

If you are updating the sample data to cope with modifications to the
database schema, you need to be aware that the sample data is loaded
*after* the database and all its patches are built. It is fairly simple
if you follow these steps:

    1.  Make sure your patch will *not* be run when you run 'make'
        in database/schema. Either rename it or leave it in the
        database/schema/pending directory.

    2.  Follow steps 1 & 2 from the previous section 'Overview'

    3.  Run the pending database schema patch (if any)

    4.  Follow steps 3 - 7 from the previous section 'Overview'.

    5.  Move the pending/renamed patch to its final location

    6.  Run 'make check' again because we are paranoid.

    7.  Follow step 8 from the previous section 'Overview'.

This process should generally only be performed by the acting DBA.
Work that needs to be committed at the same time as database patches
should be committed to a branch where the acting DBA can either inspect
and give you the go ahead to commit, or for the acting DBA to simply
tell PQM to merge in on your behalf. This should simply be a case of
doing::

    baz branch launchpad--whatever--42
    baz commit -s 'Commit changes. Ready for merge pending DBA approval'
    baz mirror

The acting DBA can then happily checkout your code from your chinstrap
archive mirror::

    baz get some.twonk@canonical.com/launchpad--whatever--42
    [ ... inspect and abuse ... ]

TODO: Confirm & document method to merge branch into trunk, avoiding loops.

Policies
--------

Creating sample data is tedious. Very. So to simplify our lives, please
just use the following core items in your sample data. In other words,
only record new sample data that references the following KEY OBJECTS:

  Person:
    12  Sample Person
    17  Ubuntu Team

In other words, we have an example of a person (12) and a team (17).
Please use one or other of these Person's for any new sample data
you create.

  Project:
    1   Ubuntu
    4   Mozilla
    5   GNOME


  Product:
    5   Evolution (in the GNOME Project 5)
    6   Gnome Terminal (in the GNOME Project 5)
    4   Firefox (project 4)
    4   Thunderbird (project 4)


  SourcePackage:
    1   Firefox
    2   Thunderbird
    8   Evolution