diff options
| author | Barry Warsaw | 2012-04-08 10:15:29 -0600 |
|---|---|---|
| committer | Barry Warsaw | 2012-04-08 10:15:29 -0600 |
| commit | 2410fe8c2578fbd11275cfc7fc1897173eecd41a (patch) | |
| tree | 77d5e612f2efd1844bb777102067f3f658aa499c /src/mailman/database/docs | |
| parent | 7abcd4faa1553fb012020b6204fb8b6208fa5bf2 (diff) | |
| download | mailman-2410fe8c2578fbd11275cfc7fc1897173eecd41a.tar.gz mailman-2410fe8c2578fbd11275cfc7fc1897173eecd41a.tar.zst mailman-2410fe8c2578fbd11275cfc7fc1897173eecd41a.zip | |
- Refactor the way databases are schema-migrated so that load_migrations()
can be tested separately.
- Add an `until` argument to load_migrations() so that we can load only up to
a given timestamp.
- In load_migrations(), ignore files in which the `version` part of the file
name is empty.
- In migrations.rst, use the new, better way of ensuring post-test cleanup.
- Add tests for partial upgrades.
- LP: #971013 - schema migrations for beta 2.
- LP: #967238 - IMailingList.archive + IMailingList.archive_private ->
IMailingList.archive_policy, and add ArchivePolicy enum.
- Move the `chdir` context manager to helpers.py and add `temporary_db`
context manager.
Diffstat (limited to 'src/mailman/database/docs')
| -rw-r--r-- | src/mailman/database/docs/migration.rst | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/mailman/database/docs/migration.rst b/src/mailman/database/docs/migration.rst index 9897b1ef2..999700ca7 100644 --- a/src/mailman/database/docs/migration.rst +++ b/src/mailman/database/docs/migration.rst @@ -55,6 +55,14 @@ specified in the configuration file. ... migrations_path: migrations ... """) +.. Clean this up at the end of the doctest. + >>> def cleanup(): + ... import shutil + ... from mailman.config import config + ... config.pop('migrations') + ... shutil.rmtree(tempdir) + >>> cleanups.append(cleanup) + Here is an example migrations module. The key part of this interface is the ``upgrade()`` method, which takes four arguments: @@ -138,9 +146,32 @@ We do not get an 802 marker because the migration has already been loaded. 00000000000801 20120211000000 -.. Clean up the temporary directory:: - >>> config.pop('migrations') - >>> sys.path.remove(tempdir) - >>> import shutil - >>> shutil.rmtree(tempdir) +Partial upgrades +================ + +It's possible (mostly for testing purposes) to only do a partial upgrade, by +providing a timestamp to `load_migrations()`. To demonstrate this, we add two +additional migrations, intended to be applied in sequential order. + + >>> from shutil import copyfile + >>> from mailman.testing.helpers import chdir + >>> with chdir(path): + ... copyfile('mm_20120211000000.py', 'mm_20120211000002.py') + ... copyfile('mm_20120211000000.py', 'mm_20120211000003.py') + ... copyfile('mm_20120211000000.py', 'mm_20120211000004.py') + +Now, only migrate to the ...03 timestamp. + + >>> config.db.load_migrations('20120211000003') + +You'll notice that the ...04 version is not present. + + >>> results = config.db.store.find(Version, component='schema') + >>> for result in sorted(result.version for result in results): + ... print result + 00000000000000 + 20120211000000 + 20120211000001 + 20120211000002 + 20120211000003 |
