summaryrefslogtreecommitdiff
path: root/tests/test_postgresql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-09-17 15:26:32 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-09-17 15:42:22 -0400
commit1dc690d40cbb61496ad8de1f1f225ddaa18f7351 (patch)
treefe3ea70b741ec75f261129b101af2e469852eead /tests/test_postgresql.py
parentf0701469c3a3eca5515bef75f0aa7fcdc481e3d0 (diff)
downloadalembic-1dc690d40cbb61496ad8de1f1f225ddaa18f7351.tar.gz
Add autocommit_block
Added new feature :meth:`.MigrationContext.autocommit_block`, a special directive which will provide for a non-transactional block inside of a migration script. The feature requres that: the database driver (e.g. DBAPI) supports the AUTOCOMMIT isolation mode. The directive also necessarily needs to COMMIT the existing transaction in progress in order to enter autocommit mode. Change-Id: I107fe9772595db189b6ebeba6535ac8f275b3fe5 Fixes: #123
Diffstat (limited to 'tests/test_postgresql.py')
-rw-r--r--tests/test_postgresql.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py
index 28de487..abc43ea 100644
--- a/tests/test_postgresql.py
+++ b/tests/test_postgresql.py
@@ -269,6 +269,24 @@ class PostgresqlOpTest(TestBase):
context.assert_("COMMENT ON TABLE foo.t2 IS NULL")
+class PGAutocommitBlockTest(TestBase):
+ def setUp(self):
+ self.conn = conn = config.db.connect()
+
+ with conn.begin():
+ conn.execute("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');")
+
+ def tearDown(self):
+ with self.conn.begin():
+ self.conn.execute("DROP TYPE mood")
+
+ def test_alter_enum(self):
+ context = MigrationContext.configure(connection=self.conn)
+ with context.begin_transaction(_per_migration=True):
+ with context.autocommit_block():
+ context.execute("ALTER TYPE mood ADD VALUE 'soso'")
+
+
class PGOfflineEnumTest(TestBase):
def setUp(self):
staging_env()