From e3e59ede4d4c3885c99d6e5e8d50c2391a289a70 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 30 Nov 2011 14:23:03 -0500 Subject: [PATCH] switch to "from alembic import op" as its not a debate worth having...probably clearer too --- alembic/templates/generic/script.py.mako | 2 +- alembic/templates/multidb/script.py.mako | 2 +- alembic/templates/pylons/script.py.mako | 2 +- docs/build/tutorial.rst | 14 +++++++------- tests/__init__.py | 18 +++++++++--------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/alembic/templates/generic/script.py.mako b/alembic/templates/generic/script.py.mako index b17c3ad3..04e4de71 100644 --- a/alembic/templates/generic/script.py.mako +++ b/alembic/templates/generic/script.py.mako @@ -9,7 +9,7 @@ Create Date: ${create_date} # downgrade revision identifier, used by Alembic. down_revision = ${repr(down_revision)} -from alembic.op import * +from alembic import op import sqlalchemy as sa ${imports if imports else ""} diff --git a/alembic/templates/multidb/script.py.mako b/alembic/templates/multidb/script.py.mako index b9e606ca..32529c68 100644 --- a/alembic/templates/multidb/script.py.mako +++ b/alembic/templates/multidb/script.py.mako @@ -9,7 +9,7 @@ Create Date: ${create_date} # downgrade revision identifier, used by Alembic. down_revision = ${repr(down_revision)} -from alembic.op import * +from alembic import op import sqlalchemy as sa ${imports if imports else ""} diff --git a/alembic/templates/pylons/script.py.mako b/alembic/templates/pylons/script.py.mako index b17c3ad3..04e4de71 100644 --- a/alembic/templates/pylons/script.py.mako +++ b/alembic/templates/pylons/script.py.mako @@ -9,7 +9,7 @@ Create Date: ${create_date} # downgrade revision identifier, used by Alembic. down_revision = ${repr(down_revision)} -from alembic.op import * +from alembic import op import sqlalchemy as sa ${imports if imports else ""} diff --git a/docs/build/tutorial.rst b/docs/build/tutorial.rst index ad8b85b4..ab55ce5d 100644 --- a/docs/build/tutorial.rst +++ b/docs/build/tutorial.rst @@ -203,7 +203,7 @@ A new file ``1975ea83b712.py`` is generated. Looking inside the file:: # downgrade revision identifier, used by Alembic. down_revision = None - from alembic.op import * + from alembic import op import sqlalchemy as sa def upgrade(): @@ -303,14 +303,14 @@ Let's edit this file and add a new column to the ``account`` table:: # downgrade revision identifier, used by Alembic. down_revision = '1975ea83b712' - from alembic.op import * + from alembic import op import sqlalchemy as sa def upgrade(): - add_column('account', sa.Column('last_transaction_date', sa.DateTime)) + op.add_column('account', sa.Column('last_transaction_date', sa.DateTime)) def downgrade(): - drop_column('account', 'last_transaction_date') + op.drop_column('account', 'last_transaction_date') Running again to ``head``:: @@ -441,12 +441,12 @@ is already present:: # downgrade revision identifier, used by Alembic. down_revision = None - from alembic.op import * + from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### - create_table( + op.create_table( 'account', sa.Column('id', sa.Integer()), sa.Column('name', sa.String(length=50), nullable=False), @@ -458,7 +458,7 @@ is already present:: def downgrade(): ### commands auto generated by Alembic - please adjust! ### - drop_table("account") + op.drop_table("account") ### end Alembic commands ### The migration hasn't actually run yet, of course. We do that via the usual ``upgrade`` diff --git a/tests/__init__.py b/tests/__init__.py index 9013d8e4..10ce3ae4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -282,13 +282,13 @@ def three_rev_fixture(cfg): script.write(a, """ down_revision = None -from alembic.op import * +from alembic import op def upgrade(): - execute("CREATE STEP 1") + op.execute("CREATE STEP 1") def downgrade(): - execute("DROP STEP 1") + op.execute("DROP STEP 1") """) @@ -296,13 +296,13 @@ def downgrade(): script.write(b, """ down_revision = '%s' -from alembic.op import * +from alembic import op def upgrade(): - execute("CREATE STEP 2") + op.execute("CREATE STEP 2") def downgrade(): - execute("DROP STEP 2") + op.execute("DROP STEP 2") """ % a) @@ -310,13 +310,13 @@ def downgrade(): script.write(c, """ down_revision = '%s' -from alembic.op import * +from alembic import op def upgrade(): - execute("CREATE STEP 3") + op.execute("CREATE STEP 3") def downgrade(): - execute("DROP STEP 3") + op.execute("DROP STEP 3") """ % b) return a, b, c \ No newline at end of file -- 2.47.2