|
a/pyforge/flyway/command.py |
|
b/pyforge/flyway/command.py |
|
... |
|
... |
20 |
parser.add_option('-l', '--logging', dest='logging_config_file',
|
20 |
parser.add_option('-l', '--logging', dest='logging_config_file',
|
21 |
default=None)
|
21 |
default=None)
|
22 |
parser.add_option('--log-level', dest='log_level', default='INFO')
|
22 |
parser.add_option('--log-level', dest='log_level', default='INFO')
|
23 |
parser.add_option('--reset', dest='reset', action='store_true', default=False)
|
23 |
parser.add_option('--reset', dest='reset', action='store_true', default=False)
|
24 |
parser.add_option('-d', '--dry-run', dest='dry_run', action='store_true', default=False)
|
24 |
parser.add_option('-d', '--dry-run', dest='dry_run', action='store_true', default=False)
|
|
|
25 |
parser.add_option('-s', '--status', dest='status_only', action='store_true', default=False)
|
|
|
26 |
parser.add_option('--force', dest='force', action='store_true', default=False)
|
25 |
|
27 |
|
26 |
def command(self):
|
28 |
def command(self):
|
27 |
self._setup_logging()
|
29 |
self._setup_logging()
|
28 |
self._load_migrations()
|
30 |
self._load_migrations()
|
29 |
from .runner import run_migration, reset_migration
|
31 |
from .runner import run_migration, reset_migration, show_status, set_status
|
30 |
parsed_connection_url = parse_uri(self.options.connection_url)
|
32 |
parsed_connection_url = parse_uri(self.options.connection_url)
|
31 |
if not parsed_connection_url['path']:
|
33 |
if not parsed_connection_url['path']:
|
32 |
parsed_connection_url['path'] += '/'
|
34 |
parsed_connection_url['path'] += '/'
|
33 |
if parsed_connection_url['path'] == '/':
|
35 |
if parsed_connection_url['path'] == '/':
|
34 |
# Find all the databases managed by the server
|
36 |
# Find all the databases managed by the server
|
|
... |
|
... |
43 |
self.log.info('Migrate server: %s:%s',
|
45 |
self.log.info('Migrate server: %s:%s',
|
44 |
parsed_connection_url['host'],
|
46 |
parsed_connection_url['host'],
|
45 |
parsed_connection_url['port'])
|
47 |
parsed_connection_url['port'])
|
46 |
for ds in datastores:
|
48 |
for ds in datastores:
|
47 |
self.log.info('Migrate DB: %s', ds.database)
|
49 |
self.log.info('Migrate DB: %s', ds.database)
|
|
|
50 |
if self.options.status_only:
|
|
|
51 |
show_status(ds)
|
|
|
52 |
elif self.options.force:
|
|
|
53 |
set_status(ds, self._target_versions())
|
48 |
if self.options.reset:
|
54 |
elif self.options.reset:
|
49 |
reset_migration(ds, dry_run=self.options.dry_run)
|
55 |
reset_migration(ds, dry_run=self.options.dry_run)
|
50 |
else:
|
56 |
else:
|
51 |
run_migration(ds, self._target_versions(), dry_run=self.options.dry_run)
|
57 |
run_migration(ds, self._target_versions(), dry_run=self.options.dry_run)
|
52 |
|
58 |
|
53 |
def _setup_logging(self):
|
59 |
def _setup_logging(self):
|