Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: database/migrate.py

Issue 1595019: Merge remote branch 'origin/upstream' into tempbranch (Closed)
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/tests/profiler_sync/profiler_sync.py ('k') | database/schema_051.sql » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python -u 1 #!/usr/bin/python -u
2 2
3 import os, sys, re, subprocess, tempfile 3 import os, sys, re, subprocess, tempfile
4 from optparse import OptionParser 4 from optparse import OptionParser
5 import common 5 import common
6 import MySQLdb, MySQLdb.constants.ER 6 import MySQLdb, MySQLdb.constants.ER
7 from autotest_lib.client.common_lib import global_config, utils 7 from autotest_lib.client.common_lib import global_config, utils
8 from autotest_lib.database import database_connection 8 from autotest_lib.database import database_connection
9 9
10 MIGRATE_TABLE = 'migrate_info' 10 MIGRATE_TABLE = 'migrate_info'
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 assert self.get_db_version() == version 197 assert self.get_db_version() == version
198 print 'At version', version 198 print 'At version', version
199 199
200 200
201 def _migrate_from_base(self): 201 def _migrate_from_base(self):
202 self.confirm_initialization() 202 self.confirm_initialization()
203 203
204 migration_script = utils.read_file( 204 migration_script = utils.read_file(
205 os.path.join(os.path.dirname(__file__), 'schema_051.sql')) 205 os.path.join(os.path.dirname(__file__), 'schema_051.sql'))
206 migration_script = migration_script % (
207 dict(username=self._database.get_database_info()['username']))
206 self.execute_script(migration_script) 208 self.execute_script(migration_script)
207 209
208 self.create_migrate_table() 210 self.create_migrate_table()
209 self.set_db_version(51) 211 self.set_db_version(51)
210 212
211 213
212 def confirm_initialization(self): 214 def confirm_initialization(self):
213 if not self.force: 215 if not self.force:
214 response = raw_input( 216 response = raw_input(
215 'Your %s database does not appear to be initialized. Do you ' 217 'Your %s database does not appear to be initialized. Do you '
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 def get_migration_manager(db_name, debug, force): 373 def get_migration_manager(db_name, debug, force):
372 database = database_connection.DatabaseConnection(db_name) 374 database = database_connection.DatabaseConnection(db_name)
373 database.debug = debug 375 database.debug = debug
374 database.reconnect_enabled = False 376 database.reconnect_enabled = False
375 database.connect() 377 database.connect()
376 return MigrationManager(database, force=force) 378 return MigrationManager(database, force=force)
377 379
378 380
379 if __name__ == '__main__': 381 if __name__ == '__main__':
380 main() 382 main()
OLDNEW
« no previous file with comments | « client/tests/profiler_sync/profiler_sync.py ('k') | database/schema_051.sql » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698