~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/schema/reset_sequences.py

[r=sinzui][bug=855670] Add additional checks to the private team
        launchpad.LimitedView security adaptor so more users in defined
        roles can see the team.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python -S
 
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
 
 
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
 
 
17
# pylint: disable-msg=W0403
 
18
import _pythonpath
 
19
 
 
20
from optparse import OptionParser
 
21
from canonical.database.postgresql import resetSequences
 
22
from canonical.database.sqlbase import connect
 
23
from lp.services.scripts import db_options
 
24
 
 
25
if __name__ == '__main__':
 
26
    parser = OptionParser()
 
27
    db_options(parser)
 
28
    (options, args) = parser.parse_args()
 
29
    if args:
 
30
        parser.error("Too many options given")
 
31
    if not options.dbname:
 
32
        parser.error("Required option --dbname not given")
 
33
    con = connect()
 
34
    resetSequences(con.cursor())
 
35
    con.commit()