fix issues with ConfigParser and existing repositories (fixes issue 115)
This commit is contained in:
parent
0c069a63c7
commit
18c3f68d41
@ -11,8 +11,8 @@ Features
|
|||||||
******************
|
******************
|
||||||
|
|
||||||
- improved PEP-8 compliance (issue 122)
|
- improved PEP-8 compliance (issue 122)
|
||||||
- optionally number versions with timestamps instead of sequences (by Pete
|
- optionally number versions with timestamps instead of sequences (partly
|
||||||
Keen)
|
pulled from Pete Keen)
|
||||||
- allow descriptions in SQL change script filenames (by Pete Keen)
|
- allow descriptions in SQL change script filenames (by Pete Keen)
|
||||||
- improved model generation
|
- improved model generation
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class TestVersionedRepository(fixture.Pathed):
|
|||||||
|
|
||||||
def test_timestmap_numbering_version(self):
|
def test_timestmap_numbering_version(self):
|
||||||
repos = Repository(self.path_repos)
|
repos = Repository(self.path_repos)
|
||||||
repos.config.set('db_settings', 'use_timestamp_numbering', True)
|
repos.config.set('db_settings', 'use_timestamp_numbering', 'True')
|
||||||
|
|
||||||
# Get latest version, or detect if a specified version exists
|
# Get latest version, or detect if a specified version exists
|
||||||
self.assertEquals(repos.latest, 0)
|
self.assertEquals(repos.latest, 0)
|
||||||
|
@ -115,7 +115,7 @@ class Repository(pathed.Pathed):
|
|||||||
options.setdefault('version_table', 'migrate_version')
|
options.setdefault('version_table', 'migrate_version')
|
||||||
options.setdefault('repository_id', name)
|
options.setdefault('repository_id', name)
|
||||||
options.setdefault('required_dbs', [])
|
options.setdefault('required_dbs', [])
|
||||||
options.setdefault('use_timestamp_numbering', '0')
|
options.setdefault('use_timestamp_numbering', False)
|
||||||
|
|
||||||
tmpl = open(os.path.join(tmpl_dir, cls._config)).read()
|
tmpl = open(os.path.join(tmpl_dir, cls._config)).read()
|
||||||
ret = TempitaTemplate(tmpl).substitute(options)
|
ret = TempitaTemplate(tmpl).substitute(options)
|
||||||
@ -180,9 +180,9 @@ class Repository(pathed.Pathed):
|
|||||||
@property
|
@property
|
||||||
def use_timestamp_numbering(self):
|
def use_timestamp_numbering(self):
|
||||||
"""Returns use_timestamp_numbering specified in config"""
|
"""Returns use_timestamp_numbering specified in config"""
|
||||||
ts_numbering = self.config.get('db_settings', 'use_timestamp_numbering', raw=True)
|
if self.config.has_option('db_settings', 'use_timestamp_numbering'):
|
||||||
|
return self.config.getboolean('db_settings', 'use_timestamp_numbering')
|
||||||
return ts_numbering
|
return False
|
||||||
|
|
||||||
def version(self, *p, **k):
|
def version(self, *p, **k):
|
||||||
"""API to :attr:`migrate.versioning.version.Collection.version`"""
|
"""API to :attr:`migrate.versioning.version.Collection.version`"""
|
||||||
|
@ -22,4 +22,4 @@ required_dbs={{ locals().pop('required_dbs') }}
|
|||||||
# When creating new change scripts, Migrate will stamp the new script with
|
# When creating new change scripts, Migrate will stamp the new script with
|
||||||
# a version number. By default this is latest_version + 1. You can set this
|
# a version number. By default this is latest_version + 1. You can set this
|
||||||
# to 'true' to tell Migrate to use the UTC timestamp instead.
|
# to 'true' to tell Migrate to use the UTC timestamp instead.
|
||||||
use_timestamp_numbering='false'
|
use_timestamp_numbering={{ locals().pop('use_timestamp_numbering') }}
|
||||||
|
@ -18,3 +18,8 @@ version_table={{ locals().pop('version_table') }}
|
|||||||
# be using to ensure your updates to that database work properly.
|
# be using to ensure your updates to that database work properly.
|
||||||
# This must be a list; example: ['postgres','sqlite']
|
# This must be a list; example: ['postgres','sqlite']
|
||||||
required_dbs={{ locals().pop('required_dbs') }}
|
required_dbs={{ locals().pop('required_dbs') }}
|
||||||
|
|
||||||
|
# When creating new change scripts, Migrate will stamp the new script with
|
||||||
|
# a version number. By default this is latest_version + 1. You can set this
|
||||||
|
# to 'true' to tell Migrate to use the UTC timestamp instead.
|
||||||
|
use_timestamp_numbering={{ locals().pop('use_timestamp_numbering') }}
|
||||||
|
@ -90,9 +90,7 @@ class Collection(pathed.Pathed):
|
|||||||
return max([VerNum(0)] + self.versions.keys())
|
return max([VerNum(0)] + self.versions.keys())
|
||||||
|
|
||||||
def _next_ver_num(self, use_timestamp_numbering):
|
def _next_ver_num(self, use_timestamp_numbering):
|
||||||
print use_timestamp_numbering
|
|
||||||
if use_timestamp_numbering == True:
|
if use_timestamp_numbering == True:
|
||||||
print "Creating new timestamp version!"
|
|
||||||
return VerNum(int(datetime.utcnow().strftime('%Y%m%d%H%M%S')))
|
return VerNum(int(datetime.utcnow().strftime('%Y%m%d%H%M%S')))
|
||||||
else:
|
else:
|
||||||
return self.latest + 1
|
return self.latest + 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user