10637.3.7
by Guilherme Salgado
merge devel |
1 |
#!/usr/bin/python -S
|
8687.15.9
by Karl Fogel
Add the copyright header block to more files (everything under database/). |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
1717
by Canonical.com Patch Queue Manager
[r=spiv] Misc pending changes, including ProductSeries.name changing for bazaar imports, wiring up Daf's sampledata sorting script, enhancing the PostgreSQL test harness to ensure better test isolation (solves the issue of not resetting sequence values between tests, a possible case of occasional test failures). |
6 |
"""
|
7 |
The sampledata does not update the current values of all the sequences
|
|
8 |
used to populate the primary keys (this was removed to aid in merging changes
|
|
9 |
to the sampledata).
|
|
10 |
||
11 |
This script resets all of these sequences to the correct value based on the
|
|
12 |
maximum value currently found in the corresponding table.
|
|
13 |
"""
|
|
14 |
||
15 |
__metaclass__ = type |
|
16 |
||
8677.1.3
by Stuart Bishop
All scripts need to import _pythonpath to function correctly with buildout |
17 |
# pylint: disable-msg=W0403
|
18 |
import _pythonpath |
|
1717
by Canonical.com Patch Queue Manager
[r=spiv] Misc pending changes, including ProductSeries.name changing for bazaar imports, wiring up Daf's sampledata sorting script, enhancing the PostgreSQL test harness to ensure better test isolation (solves the issue of not resetting sequence values between tests, a possible case of occasional test failures). |
19 |
|
20 |
from optparse import OptionParser |
|
21 |
from canonical.database.postgresql import resetSequences |
|
22 |
from canonical.database.sqlbase import connect |
|
23 |
||
24 |
if __name__ == '__main__': |
|
25 |
parser = OptionParser() |
|
26 |
parser.add_option( |
|
27 |
"-d", "--dbname", dest="dbname", help="database name", |
|
28 |
)
|
|
29 |
(options, args) = parser.parse_args() |
|
30 |
if args: |
|
31 |
parser.error("Too many options given") |
|
32 |
if not options.dbname: |
|
33 |
parser.error("Required option --dbname not given") |
|
34 |
con = connect(None, options.dbname) |
|
35 |
resetSequences(con.cursor()) |
|
36 |
con.commit() |
|
37 |