Re: Import data to alembic migrations

2022-05-10 Thread Mike Bayer
yes, one particular approach to this issue is discussed here: https://alembic.sqlalchemy.org/en/latest/front.html#installation start with that if nothing else is working (There are many ways to do this). On Tue, May 10, 2022, at 5:34 AM, Ilya Demidov wrote: > Hi! > > I have some problem. I ne

Re: [Renaming Alembic Table]

2022-04-11 Thread Mike Bayer
On Mon, Apr 11, 2022, at 12:47 AM, arvind aithal wrote: > Is it possible to rename the alembic table name to customised one? > > Once we run the migrations it creates *alembic_version table* which stores > the version. > > After init, when we run command migrate, by default it generates > a

Re: alembic upgrade heads

2021-08-25 Thread Mike Bayer
seems like you should ensure that Alembic is installed in the current Python environment. looks like it is not installed correctly. On Wed, Aug 25, 2021, at 2:23 PM, Vinod Rao wrote: > Hi all: > > I have been struggling to solve the following error: > > File "/virtual_env/bin/alembic", lin

Re: Managing multiple tenant "namespaces"

2021-04-16 Thread Mike Bayer
On Fri, Apr 16, 2021, at 7:15 AM, Nikola Radovanovic wrote: > Hi, > we have one Postgres DB with multiple schemes: > 1. general (one schema, contains users and some common and data shared > between clients/clusters) > 2. client schemes: c_client_1, c_client_2, c_client_3, etc. (all clients >

Re: Managing multiple tenant "namespaces"

2021-04-09 Thread Mike Bayer
On Wed, Apr 7, 2021, at 5:18 AM, Nikola Radovanovic wrote: > Hi, > I have a bit unusual use-case in software I work on. > > There are three main "namespaces" (kinds of data): first one is "general" > (not multi-tenant), where we keep some common security and settings data. > > Second one is "

Re: branch merge schema conflict

2021-03-09 Thread Mike Bayer
just so you know, surgical-precision downgrades will be more reliable once we get the 1.6 series of Alembic out, where we have a total rewrite of how the internal traversal works in order to make upgrade/downgrades across complex trees more reliable. downgrades are not *too* common in produ

Re: branch merge schema conflict

2021-03-09 Thread Mike Bayer
On Tue, Mar 9, 2021, at 5:06 PM, 'br...@derocher.org' via sqlalchemy-alembic wrote: > I'm wondering how to solve an issue. > > One developer created migration 1efb > > upgrade: > drop view v1 -- moved to query in the code > > downgrade: >create view v1 as select 1 > > Another develope

Re: ask for help on best practices when changing table name from uppercase to lowercase

2021-01-05 Thread Mike Bayer
On Tue, Jan 5, 2021, at 9:50 AM, kz...@us.ibm.com wrote: > Thanks mike! > > I understand that it should work when querying over SQLAlchemy API. the > missing part of my use case I forgot to provide is, it only uses > Alembic/SQLAlchemy to manage schema changes, while the actual query may comes

Re: ask for help on best practices when changing table name from uppercase to lowercase

2021-01-04 Thread Mike Bayer
This is the casing convention of the database and SQLAlchemy does not consider the name to be in "uppercase" or "lowercase" (or even "mixed case") but rather "case insensitive", which really means the name is referred towards without any quoting.When no quoting is applied, there is essential

Re: Example of inline autogenerated use?

2020-11-05 Thread Mike Bayer
Not quite given in an example, I guess I could add as a recipe but then people will be using it which as you've noted isn't reliable in the general sense, let's put together how to get the MigrationScript, which it looks like you have, with then how to make the Operations object programmatically

Re: command.init api ignores the cfg settings

2020-10-09 Thread Mike Bayer
hi there - this question lacks specifics. There are no configuration options that are relevant to the "alembic init" command in any case so it's not clear what config settings you are seeing as "ignored"; init uses only the name of the ini file given and this works: from alembic.config impor

Re: Use events with expression api

2020-09-30 Thread Mike Bayer
SQL expressions are intercepted by the SQL Execution events described at https://docs.sqlalchemy.org/en/13/core/events.html#sql-execution-and-connection-events and the main ones are before_execute() and before_cursor_execute(), but it depends on what you want to do.if you want to change how

Re: Stray changes detected only sometimes with revision --autogenerate

2020-09-30 Thread Mike Bayer
pulate the `conn_table_names` object > in-place. But since that's gone now, everything is working as expected \o/ > > Thank you so much for your help! > > Cheers, > Daniel > > On 29.09.20 19:04, Mike Bayer wrote: > > > > > > Hi, so I added a quick

Re: Stray changes detected only sometimes with revision --autogenerate

2020-09-29 Thread Mike Bayer
Hi, so I added a quick recipe to the site just now just so that the "set search path" idea is documented to some extent, that is at https://alembic.sqlalchemy.org/en/latest/cookbook.html#rudimental-schema-level-multi-tenancy-for-postgresql-databases . Re: autogenerate, if you have many schema

Re: Stray changes detected only sometimes with revision --autogenerate

2020-09-29 Thread Mike Bayer
On Tue, Sep 29, 2020, at 3:35 PM, Mike Bayer wrote: > > > On Tue, Sep 29, 2020, at 9:17 AM, Daniel Krebs wrote: >> Hi, >> >> we're having rather strange problems with Alembic 1.4.2 and Postgres 12, >> detecting stray changes *sometimes* but also someti

Re: Stray changes detected only sometimes with revision --autogenerate

2020-09-29 Thread Mike Bayer
On Tue, Sep 29, 2020, at 9:17 AM, Daniel Krebs wrote: > Hi, > > we're having rather strange problems with Alembic 1.4.2 and Postgres 12, > detecting stray changes *sometimes* but also sometimes not. I already dug > through the code but I increasingly get the feel that this is rooted > somewhe

Re: KeyError: 'sqlnotapplicable' when running alembic revision --autogenerate

2020-09-04 Thread Mike Bayer
this warning is the culprit: SAWarning: index key 'sqlnotapplicable' was not located in columns for table ‘github_active_users' I believe you should report this to the ibm_db_sa folks. https://github.com/ibmdb/python-ibmdbsa/issues you would need to share the "CREATE TABLE" statements whic

Re: Delay between consecutive SQL statements when using Alembic on Jenkins

2020-08-17 Thread Mike Bayer
On Sun, Aug 16, 2020, at 11:10 PM, Michał Guzek wrote: > I have a problem with delays between consecutive SQL statements when Alembic > executes a migration script's upgrade() function on Jenkins: > def upgrade(): > op.execute("DELETE FROM employee WHERE name='John';") #John also has its > pri

Re: 'alembic current' crashes with stack trace

2020-03-26 Thread Mike Bayer
Somewhere in your model, likely inside of a Table() object, there is a keyword "index" being used which is invalid. Look for that keyword and remove it. On Thu, Mar 26, 2020, at 1:53 PM, Rob Schottland wrote: > Suddenly, I can't get alembic (1.3.3?). alembic history does work, but my > most

Re: Autogenerate with Multi-Tenant

2020-03-20 Thread Mike Bayer
n(): > context.run_migrations() > > it works when my schema is 'public', when it matches metadata. my solution > will be to set my schema to 'public' and use this simple env.py. > > thanks, > > brian > > On Friday, March 20, 2020 at 9:49:52 AM UTC-

Re: Autogenerate with Multi-Tenant

2020-03-20 Thread Mike Bayer
t; On Thursday, March 19, 2020 at 8:20:06 PM UTC-4, Mike Bayer wrote: >> >> >> On Thu, Mar 19, 2020, at 7:41 PM, Brian Hill wrote: >>> >>> >>> On Thursday, March 19, 2020 at 7:19:08 PM UTC-4, Mike Bayer wrote: >>>> so let me get this straig

Re: Autogenerate with Multi-Tenant

2020-03-19 Thread Mike Bayer
On Thu, Mar 19, 2020, at 7:41 PM, Brian Hill wrote: > > > On Thursday, March 19, 2020 at 7:19:08 PM UTC-4, Mike Bayer wrote: >> so let me get this straight: >> >> 1. you have many schemas >> > > yes > >> >> 2. you want to run

Re: Autogenerate with Multi-Tenant

2020-03-19 Thread Mike Bayer
h. you might need to disable the schema translate map when autogenerate runs but try it without doing that first. On Thu, Mar 19, 2020, at 7:09 PM, Brian Hill wrote: > Here's my env.py. Thanks for the help. > Brian > > On Thursday, March 19, 2020 at 5:37:38 PM UTC-4, Mike Bayer

Re: Autogenerate with Multi-Tenant

2020-03-19 Thread Mike Bayer
On Thu, Mar 19, 2020, at 5:30 PM, Brian Hill wrote: > Are there known issues with using autogenerate with multi-tenant > (schema_translate_map)? it's complicated and not one-size-fits-all, if you consider that to be an issue > > My metadata doesn't have a schema and I my > schema_translate_

Re: Invoke commands with custom env.py from library

2020-03-05 Thread Mike Bayer
them making any changes? If there is truly something blocking ScriptDirectory from working this way, maybe I'd suggest monkeypatching, but script_directory and version_locations look separate to me and are handled separately all the way from ScriptDirectory.from_config(). > > O

Re: Invoke commands with custom env.py from library

2020-03-05 Thread Mike Bayer
f the migration command is targeting the project "foo"'s local > migrations/versions folder > > The specifics of the above are just based on my knowledge of alembic, so if > there's another process i could be doing where env.py isn't "invoked" so much

Re: Invoke commands with custom env.py from library

2020-03-05 Thread Mike Bayer
On Thu, Mar 5, 2020, at 8:08 AM, Daniel Cardin wrote: > I am attempting to write a library which invokes alembic commands, while > referencing the migrations of a separate package which has installed said > library. > > The intent here, is for the library to invoke the alembic commands with an

Re: Alembic: Change the order of the columns for a table

2020-03-04 Thread Mike Bayer
would be why. It would probably work to set col.unique=False, col.index=False before applying the Column to the new operation so that these don't double up for the constraints that we are already getting from the table. let me know if that works and we can update the demo. > > Th

Re: Alembic: Change the order of the columns for a table

2020-03-03 Thread Mike Bayer
On Tue, Mar 3, 2020, at 3:36 AM, David Siller wrote: > Hello, > > first and foremost: thank you for SQLAlchemy and Alembic. I've worked with a > lot of ORMs, but only with these two I feel very comfortable and I'm doing a > lot of crazy stuff with it. > > The current problem that I have: I'm

Re: How to enable verbosity on “alembic upgrade head”?

2020-02-27 Thread Mike Bayer
ryKeyConstraint('id') > ) > op.execute(""" > INSERT INTO test (language) VALUES ('en_us'); > """) > # ### end Alembic commands ### > > > I would like to see a log entry for the create table and one for the insert. > &

Re: Re: Re: Re: Integrate PyHive and Alembic

2020-02-27 Thread Mike Bayer
On Thu, Feb 27, 2020, at 2:49 PM, Ke Zhu - k...@us.ibm.com wrote: > On Wed, 2020-02-26 at 11:07 -0500, Mike Bayer wrote: >> oh, that issue is talking about rowcount. Alembic does not need rowcount to >> function correctly. I see that Alembic is doing this now, however there i

Re: How to enable verbosity on “alembic upgrade head”?

2020-02-27 Thread Mike Bayer
SQL logging will render all the SQL being emitted which should be enough to see everything the script is doing against the database. that is, if you ran op.alter_column(), you'd see "ALTER COLUMN..." in the log. not sure what else you are looking to see. do you think you're having a deadlock in

Re: How to enable verbosity on “alembic upgrade head”?

2020-02-27 Thread Mike Bayer
the --verbose flag is only used for a command like "alembic history" to provide more detail. to see Alembic doing its work you want to enable logging. in the ini file (see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file) you want to set [logger_sqlalchemy] level to I

Re: Re: Re: Integrate PyHive and Alembic

2020-02-26 Thread Mike Bayer
part can be changed on the Alembic side. > > While, the answer will be no to PrestoSQL which is just a SQL query engine > that delegates data model and data store to query targets > (MySQL/Postgres/Kafka/Elasticsearch etc) via connectors. > > On Mon, 2020-02-24 at 18:28 -0

Re: Re: Integrate PyHive and Alembic

2020-02-24 Thread Mike Bayer
but also it would be way better to store the version info in the target DB itself. I don't know anything about Hive/Presto, but they *are* databases so I'd assume you can put data in them. > > On Sat, 2020-01-25 at 18:19 -0500, Mike Bayer wrote: >> >> >>

Re: Migrate alembic_version table from Public to tenant schema

2020-02-18 Thread Mike Bayer
On Tue, Feb 18, 2020, at 1:17 PM, Brian Hill wrote: > Is there a way to move the alembic_version table in the Public schema > (postgres) to a specific schema (mult-tenant) as part of a migration? I highly doubt this is possible in the general case without the raw SQL in your env.py, because as

Re: Using enums with schema_translate_map

2020-02-17 Thread Mike Bayer
g https://github.com/sqlalchemy/sqlalchemy/issues/5158 will be fixed in 1.3.14 On Mon, Feb 17, 2020, at 2:51 PM, Mike Bayer wrote: > mm nope we have plenty of tests for this here: > > https://github.com/sqlalchemy/sqlalchemy/blob/master/test/dialect/postgresql/test_compiler.py#L223 > > &g

Re: Using enums with schema_translate_map

2020-02-17 Thread Mike Bayer
mm nope we have plenty of tests for this here: https://github.com/sqlalchemy/sqlalchemy/blob/master/test/dialect/postgresql/test_compiler.py#L223 On Mon, Feb 17, 2020, at 2:49 PM, Mike Bayer wrote: > it's possible also that PG Enum CREATE TYPE doesn't work with > schema_tran

Re: Using enums with schema_translate_map

2020-02-17 Thread Mike Bayer
it's possible also that PG Enum CREATE TYPE doesn't work with schema_translate_map, would need to evaluate that on the SQLAlchemy side. On Mon, Feb 17, 2020, at 2:45 PM, Mike Bayer wrote: > schema_translate_map is not yet supported with all Alembic ops: > > https://github.com

Re: Using enums with schema_translate_map

2020-02-17 Thread Mike Bayer
schema_translate_map is not yet supported with all Alembic ops: https://github.com/sqlalchemy/alembic/issues/555 you will need to fill in the "schema" parameter explicitly when you call upon op.create_table() On Mon, Feb 17, 2020, at 12:47 PM, Brian Hill wrote: > I'm having trouble using enum

Re: Integrate PyHive and Alembic

2020-01-25 Thread Mike Bayer
estion > <https://stackoverflow.com/questions/59887588/how-to-add-new-dialect-to-alembic-besides-built-in-dialects> > in stackoverflow but raised this group is a better place to get help. > > > On Friday, February 10, 2017 at 9:45:38 AM UTC-5, mike bayer wrote: >> >&g

Re: Automating charset encoding/collation conversion for MySQL db.

2019-12-04 Thread Mike Bayer
On Tue, Dec 3, 2019, at 7:50 PM, Jens Troeger wrote: > Hello, > > Using a MySQL database keeping Unicode strings under control turned out to be > a bit of a challenge. I could have sworn that character encoding and > collation are

Re: extending enum type natively in postgres using alembic

2019-10-31 Thread Mike Bayer
On Thu, Oct 31, 2019, at 8:45 AM, Alexander wrote: > Dear colleagues, > > I would like to extend enum type in postgres using alembic and currently i > have to do the following: > > name = 'my_type' > old_enum = sa.dialects.postgresql.ENUM('value1', 'value2', name=name) > new_enum = sa.dialects

Re: Snowflake odities and ReplaceableObject

2019-10-11 Thread Mike Bayer
I think it would be simplest to use a regular expression to pull out the symbol names from the declared function in order to write out the DROP text. Otherwise, just add additional arguments to ReplaceableObject. It's a recipe so you should change it directly, I wouldn't create new superclasses

Re: Paritioned Table Migration

2019-08-29 Thread Mike Bayer
On Thu, Aug 29, 2019, at 8:55 AM, Stephan Gerhard wrote: > Hi, > > I am wondering whether it is possible to use Alembic to define a migration > where I add a partitioned table - a feature that is supported in Postgres 12 > - e.g. using range partitions. > https://www.2ndquadrant.com/en/blog/pa

Re: How to rename column on MySQL without deleting existing data?

2019-08-27 Thread Mike Bayer
On Tue, Aug 27, 2019, at 6:15 AM, Mike wrote: > *Setup:* > mysql> SELECT version(); > > * 5.7.27-0ubuntu0.18.04.1 > * Python 3.6.8 > * SQLAlchemy 1.3.6 > * Alembic 1.0.11 > > > *models.py:* > class Experiments(db.Model): > id = db.Column(db.Integer, primary_key=True) > # country = db.Column(

Re: Alembic: Varying database names per environment?

2019-08-19 Thread Mike Bayer
On Mon, Aug 19, 2019, at 7:24 AM, Scott wrote: > On Monday, August 19, 2019 at 9:58:19 AM UTC+10, Mike Bayer wrote: >> >> >> On Sun, Aug 18, 2019, at 6:50 PM, Scott wrote: >>> Looking to use Alembic to manage migrations. >>> >>> We currently h

Re: Alembic: Varying database names per environment?

2019-08-18 Thread Mike Bayer
On Sun, Aug 18, 2019, at 6:50 PM, Scott wrote: > Looking to use Alembic to manage migrations. > > We currently have different database names in each environment, so for dev, > test and prod we have db_dev, db_test and db_prod respectively. > > Is this database naming scheme going to be compati

Re: Python 3.7 - RuntimeError: generator raised StopIteration

2019-06-28 Thread Mike Bayer
On Fri, Jun 28, 2019, at 4:01 PM, gbr wrote: > I've upgraded my application to Python 3.7 and to the latest version of > Alembic which triggers an exception when `context.get_current_revision()` is > called. > > ``` > File "app.py", line 395, in check_database_version > current_rev = context

Re: merging old versions

2019-06-20 Thread Mike Bayer
On Thu, Jun 20, 2019, at 1:45 PM, Michael Merickel wrote: > I think the basic idea is to create a database and codebase in the state of > the target revision. Then autogenerate a migration from nothing to that > revision - just like you would do when starting to use alembic from an > existing

Re: How to handle `default` column values before/after commit()

2019-05-06 Thread Mike Bayer
On Mon, May 6, 2019 at 12:06 AM wrote: > > Suppose the following code: > > # We define a base for all DB objects, currently empty. > class _Base: > pass > > Base = declarative_base(cls=_Base, metadata=MetaData(naming_convention=…)) > > # Then the objects. > class User(Base): > __tablename_

Re: Error while running “superset db upgrade” after changing metadata DB to vertica

2019-03-04 Thread Mike Bayer
Hi there - I'm not familiar with "Superset", nor does Alembic have built in support for the "Vertica" database.It looks like the Vertica SQLAlchemy drive doesn't have Alembic support implemented which at the very least would be a small stub DefaultImpl subclass.. You would need to consult wi

Re: UserDefinedType CREATE INDEX hook

2019-01-24 Thread Mike Bayer
On Thu, Jan 24, 2019 at 12:15 PM Nikola Radovanovic wrote: > > Hi, > you are right: I found that geoalchemy2 automatically creates indexes; which > I eventually turned off in model, using e.g. > > polygon = Column(Geometry(geometry_type='POLYGON', srid=3857, > spatial_index=False)) > > and addin

Re: UserDefinedType CREATE INDEX hook

2019-01-24 Thread Mike Bayer
On Thu, Jan 24, 2019 at 4:17 AM Nikola Radovanovic wrote: > > Hi all, > I have a need to use PostGIS extension in order to get support for objects > like Point and Polygon provided by geoalchemy2 in PostgreSql. > > Now, the issue I encounter is that while migrating model which uses > Point/Polyg

Re: Can I ignore it when the result of the generation is empty?

2019-01-11 Thread Mike Bayer
one thing to note with "empty" migrations is that autogenerate does not pick up things like changes of server default or datatypes unless you set some flags to turn it on, https://alembic.sqlalchemy.org/en/latest/api/runtime.html?highlight=compare_server_default#alembic.runtime.environment.Environm

Re: Multi-tenant and alembic question(s)

2018-12-23 Thread Mike Bayer
On Sun, Dec 23, 2018 at 7:40 AM Nikola Radovanovic wrote: > > Hi, > First of all, thank you for these great tools making my developer's life so > much easier and pleasant. > > I need suggestion/help on how to utilize multi-tenant schemes in Alembic. I > have few projects under the development th

Re: Save all applied migrations in alembic_version instead of the head

2018-12-18 Thread Mike Bayer
On Tue, Dec 18, 2018 at 4:02 AM Samir wrote: > > Hi all, > > Is there anyway to tell alembic to store the history of all applied > migrations and when they were applied instead of only saving the latest > migration ? There's a request for this feature at https://github.com/sqlalchemy/alembic/is

Re: many to many relation with foreign key to composite primary key

2018-12-13 Thread Mike Bayer
t; ) >> >> CREATE TABLE roles ( >> id BIGSERIAL NOT NULL, >> name VARCHAR(100) NOT NULL, >> PRIMARY KEY (id), >> UNIQUE (name) >> ) >> >> CREATE TABLE users_roles ( >> users_id BIGINT NOT NULL

Re: many to many relation with foreign key to composite primary key

2018-12-13 Thread Mike Bayer
ly ( there is no unique constraint matching given keys for referenced table "users_roles"). > I will send you the CREATE TABLE statements by email in a moment. yup > Best regards, > Patrick > > Le mer. 12 déc. 2018 à 19:40, Mike Bayer a écrit : >> >>

Re: many to many relation with foreign key to composite primary key

2018-12-12 Thread Mike Bayer
On Wed, Dec 12, 2018 at 1:01 PM patrick payet wrote: > > I had a SQLAlchemy model like - > > class User(DeclarativeBase): > __tablename__ = 'users' > > id = Column(BigInteger, primary_key=True) > email = Column(String(100), unique=True, nullable=False) > name = Column(String(100),

Re: What would be the proper way to implement a post migration hook ?

2018-12-12 Thread Mike Bayer
On Wed, Dec 12, 2018 at 10:40 AM wrote: > > Dear Alembic User Community, > > I am looking for suggestion for the best way to address the following problem: > > We have a use case where we'd like to make sure some SQL queries are always > executed after any set migration. > Our particular use case

Re: alembic autogenerated migrations do not see current tables

2018-11-21 Thread Mike Bayer
you need to have include_schemas=True in your env.py: https://alembic.zzzcomputing.com/en/latest/api/runtime.html?highlight=include_schemas#alembic.runtime.environment.EnvironmentContext.configure.params.include_schemas On Wed, Nov 21, 2018 at 11:49 AM Riccardo Magliocchetti wrote: > > Hello, >

Re: Support for "redo"

2018-11-14 Thread Mike Bayer
On Wed, Nov 14, 2018 at 6:07 AM wrote: > > Hi all! > > Is there support in Alembic for anything like the "redo" feature present in > Ruby on Rails' Active Record Migrations tool? I often find myself running an > "upgrade", followed by a "downgrade" and then finally another upgrade, in > order t

Re: alter_column missing server_onupdate?

2018-11-12 Thread Mike Bayer
server_onupdate is not an actual "server side" construct, it's a marker on the client side only to instruct SQLAlchemy that some trigger or something set up separately will be changing the value of the column when an UPDATE occurs. On Mon, Nov 12, 2018 at 1:00 AM Bert JW Regeer wrote: > > Hey all,

Re: I need to create cube field. Is it possible using sqlalchemy / alembic?

2018-11-01 Thread Mike Bayer
Assuming this is postgresql, the docuemtnation at https://www.postgresql.org/docs/11/static/cube.html does not show the actual syntax for this datatype, so let's assume it is "cube", use UserDefinedType: from sqlalchemy.types import UserDefinedType class CUBE(UserDefinedType): def get_col_spe

Re: alembic vs system=True columns

2018-10-31 Thread Mike Bayer
here's the issue: https://bitbucket.org/zzzeek/alembic/issues/515/system-true-not-generated-for-column and here is a patch to resolve: https://gerrit.sqlalchemy.org/#/c/zzzeek/alembic/+/910 On Wed, Oct 31, 2018 at 11:49 AM Riccardo Magliocchetti wrote: > > Il 31/10/18 16:32, Mi

Re: alembic vs system=True columns

2018-10-31 Thread Mike Bayer
On Wed, Oct 31, 2018 at 11:00 AM Riccardo Magliocchetti wrote: > > Hello, > > we'd like to use Postgresql xmin column for optimistic concurrency, so we > declared the column as: > > xmin = Column("xmin", Integer, system=True, server_default=FetchedValue()) > > > The problem is when autogenera

Re: Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Mike Bayer
PDATE alembic_version SET > version_num='d4aceba22da2' WHERE alembic_version.version_num = '22923a2e396c' > INFO [sqlalchemy.engine.base.Engine] {} > INFO [sqlalchemy.engine.base.Engine] COMMIT > INFO [sqlalchemy.engine.base.Engine] BEGIN (implicit) > > > > On Monda

Re: Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Mike Bayer
x27;all,delete-orphan', > backref=backref('customer', cascade='all') > ) > > class DailyMeterReading(DeclarativeBase): > __tablename__ = 'daily_smart_meter_readings' > id = Column(Integer, primary_key=True) > customer_pk = Column( >

Re: Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Mike Bayer
Hi there - I have no idea what you are seeing.an actual ALTER COLUMN operation does not delete rows. Of course, if you are using SQLite and batch mode, that might affect things, but you have not specified this. Please specify complete information including log output, stack traces, data

Re: File logger fails when used with a Gunicorn/Pyramid .ini file.

2018-09-26 Thread Mike Bayer
en/latest/tutorial.html#the-migration-environment . This should likely also be a feature so https://bitbucket.org/zzzeek/alembic/issues/509/add-support-for-the-here-s-token-when has been added. > > On Wednesday, September 26, 2018 at 10:06:31 AM UTC+10, Mike Bayer wrote: >> >>

Re: File logger fails when used with a Gunicorn/Pyramid .ini file.

2018-09-25 Thread Mike Bayer
wrote: > > Huh… I use the -c option: > > ./bin/alembic -c proj-localhost.ini upgrade head > > Jens > > > On Monday, September 24, 2018 at 11:21:42 PM UTC+10, Mike Bayer wrote: >> >> >> Looking at the source code, we already have "here&qu

Re: Migrating PEP-435 Enums

2018-09-24 Thread Mike Bayer
pe_=ENUM()) ? > > On Monday, September 24, 2018 at 2:36:52 PM UTC-4, Mike Bayer wrote: >> >> Postgresql ENUMs are entirely different from any other database so it >> matters a lot. For PG, you'd want to be doing op.execute("ALTER TYPE >> myenum ..."), ful

Re: Migrating PEP-435 Enums

2018-09-24 Thread Mike Bayer
Postgresql ENUMs are entirely different from any other database so it matters a lot. For PG, you'd want to be doing op.execute("ALTER TYPE myenum ..."), full syntax is at https://www.postgresql.org/docs/9.1/static/sql-altertype.html On Mon, Sep 24, 2018 at 12:45 PM Alex Rothberg wrote: > > Assumi

Re: File logger fails when used with a Gunicorn/Pyramid .ini file.

2018-09-24 Thread Mike Bayer
On Sun, Sep 23, 2018 at 9:53 PM wrote: > > Hello, > > In my project.ini file I have configured logging to use a file logger as > follows: > > [loggers] > keys = root, …, alembic > > [handlers] > keys = console, file > > [formatters] > keys = generic > > [logger_root] > level = INFO > handlers = c

Re: online vs offline produce different "python stack traces" and general question

2018-09-07 Thread Mike Bayer
you can change the nullability of a column with op.alter_column(). There's no need to create a separate constraint. On Thu, Sep 6, 2018 at 8:07 PM, HP3 wrote: > Sorry: > > nullable = False > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy-alembic" gr

Re: online vs offline produce different "python stack traces" and general question

2018-09-06 Thread Mike Bayer
On Thu, Sep 6, 2018 at 5:28 PM, HP3 wrote: > Hi Mike, > > I bumped up to SA to v0.9.10 and alembic completed successfully adding a > revision. IOW, I didn't have to "fudge" with neither the deadcbed_.py nor > with the .sql (offline). > > However, when running either migration (online/offline), I r

Re: online vs offline produce different "python stack traces" and general question

2018-09-06 Thread Mike Bayer
On Thu, Sep 6, 2018 at 1:14 PM, HP3 wrote: > Hello, > > As I try alembic (for the first time), I ran into the following stack traces > when attempting to conduct a "nasty" migration. > > I call it "nasty" because the original model was based on sqlalchemy v0.9 + > python 2.7 and the new model is s

Re: Run some migration revisions outside of a transaction

2018-08-10 Thread Mike Bayer
roach doesn't imply changes to env.py. > pt., 10 sie 2018 o 20:50 Mike Bayer napisał(a): > >> On Fri, Aug 10, 2018 at 2:00 PM, Michał Bultrowicz >> wrote: >> > Hey! >> > >> > What approach would you recommend if we want to run some revisions &

Re: Run some migration revisions outside of a transaction

2018-08-10 Thread Mike Bayer
On Fri, Aug 10, 2018 at 2:00 PM, Michał Bultrowicz wrote: > Hey! > > What approach would you recommend if we want to run some revisions outside > of a transaction, but then run the other ones normally? > > Let me illustrate that. Let's say we have revisions 1,2,3,4,5. The database > is currently a

Re: autogenerate revision fails in a multi-db project generated with: `alembic init --template multidb alembic`

2018-08-10 Thread Mike Bayer
On Fri, Aug 10, 2018 at 6:47 AM, wrote: > Hello > > I'm trying to use alembic to generate a migration file in a multi-db > environment. I first created the project using `alembic init --template > multidb alembic` > and then hack the `env.py` script (didn't touch to `run_migration_online`) > to s

Re: integrate with cherrypy / sqlalchemy

2018-08-01 Thread Mike Bayer
you aren't doing that, you may have to alter > your PYTHONPATH environment variable outside, or use sys.path inside > env.py in order to add where it can locate your models for import. > " > > Could you point me to documentations or examples of this? I only know what a > venv is. make y

Re: KeyError with diamond-shaped branch-merge dependency graph

2018-05-28 Thread Mike Bayer
it's likely a bug. It looks like you've done some investigation already.I don't offhand have any understanding of the issue either, I would need to build up a reproduction case and then stare at it for several hours to figure out what's happening.So first step is if you can make a bug rep

Re: render impl for custom dialect

2018-05-18 Thread Mike Bayer
See the example dialect at: https://gerrit.sqlalchemy.org/#/c/zzzeek/alembic/+/755/3/tests/test_external_dialect.py for how you can do this, with this patch. As always, I'm looking to know that this patch does everything you need before merging. On Fri, May 18, 2018 at 9:13 AM, Mike

Re: render impl for custom dialect

2018-05-18 Thread Mike Bayer
On Fri, May 18, 2018 at 7:17 AM, Антонио Антуан wrote: > Hi. > I use [that](https://github.com/xzkostyan/clickhouse-sqlalchemy) library and > tries to make migrations using alembic. > > Here is simple implementation for that dialect: > ``` > class ClickHOuseImpl(postgresql.PostgresqlImpl): > _

Re: howto transform sql create table to alembic

2018-03-28 Thread Mike Bayer
I've not done this before but all the parts are there, try it out: from sqlalchemy import create_engine from sqlalchemy import MetaData, Table from alembic import autogenerate from alembic.operations import ops e = create_engine("mysql://scott:tiger@localhost/test") with e.connect() as conn:

Re: is this a bug ?target_metadata

2018-03-26 Thread Mike Bayer
all three of your files do: from database import Base so that is just one Base object, one metadata object. they are all the same. if you wanted them separate you'd need to call upon "Base = declarative_base()" in each module individually. On Sat, Mar 24, 2018 at 1:11 PM, wrote: > mypr

Re: mssql clustered index on non-pk field

2018-03-19 Thread Mike Bayer
so process_revision_directives is a pathway here to the extent that you need to modify the autogenerate process such that a table like this is generated for you automatically. However, Alembic's normal mode of usage is that the "autogenerate" tool is only a time-saver, and is not intended to produ

Re: Applying updates to a database with an existing alembic_version

2018-03-15 Thread Mike Bayer
On Thu, Mar 15, 2018 at 5:12 AM, Jesper Larsen wrote: > I am using a project which has a database and uses alembic to upgrade the > database. The migrations are stored in the project directory. I want to > apply some custom migrations on top of these. But it seems like alembic > requires me to hav

not announcing minor releases on the mailing list or twitter for now

2018-03-06 Thread Mike Bayer
Hi all - Some of you may have noticed that several SQLAlchemy releases have gone out in the past few weeks without my customary email on these lists, nor without a tweet from the SQLAlchemy twitter account. The reason for this is that I have created scripts that comprehensively run through the ma

Re: Read the Alembic history

2018-02-21 Thread Mike Bayer
On Wed, Feb 21, 2018 at 1:18 AM, wrote: > Hello, > > Is there a supported way to get programmatic access to the history of an > Alembic migration chain? I mean, the command > >> alembic -c foo.ini history > 3bf9af8da72c -> cb13f97d30c6 (head), Table funk > 33b960335847 -> 3bf9af8da72c, Column fun

Re: Vertica support for Alembic

2018-02-08 Thread Mike Bayer
I dont know anything about Vertica, however if there is a SQLAlchemy dialect in the wild for Vertica, they can add the Alembic migration bits on that end, which starts with a small stub implementation. For example see redshift at https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/blob/mas

SQLAlchemy 1.2.2 released

2018-01-24 Thread Mike Bayer
SQLAlchemy release 1.2.2 is now available. Release 1.2.2 has a very small number of minor bug fixes and one fix of a serious ORM regression in the 1.2 series regarding relationships and backreferences. Because of the ORM issue, users of the ORM within the 1.2 series are encouraged to upgrade to 1.

SQLAlchemy 1.2.1 released

2018-01-15 Thread Mike Bayer
SQLAlchemy release 1.2.1 is now available. Release 1.2.1 fixes some minor issues for the newly released 1.2 series, including a few small regressions as well as some issues reported with the new "selectin" relationship and polymorphic loader features. Changelog for 1.2.1 is at: http://www.sqlalch

Re: A migrate thinks there's always a change with an Indexed CamelCase field since 0.92 (change 421 - 4cdb25b)

2018-01-02 Thread Mike Bayer
On Tue, Jan 2, 2018 at 2:18 PM, Seaders Oloinsigh wrote: > This change is the culprit, > > https://github.com/zzzeek/alembic/commit/4cdb25bf5d70e6e8a789c75c59a2a908433674ce#diff-e9d21bbd0f4be415139b75917420ad1c > > I've a few auto-generated tables, that are one-to-one mappings with an > external d

SQLAlchemy 1.2.0 released

2017-12-27 Thread Mike Bayer
SQLAlchemy release 1.2.0 is now available. Release 1.2.0 is the first official release in the 1.2 series, after three beta releases. The release represents the past eighteen months of new feature development since version 1.1 was released. The 1.2 series has a large mix of features and behavioral

Re: unit testing migration code

2017-12-15 Thread Mike Bayer
valent of the following but for > Alembic? > > https://github.com/plumdog/django_migration_testcase > > cheers, > > Chris > > > On 01/12/2017 15:06, Mike Bayer wrote: >> >> it's kind of a PITA but in Openstack we have fixtures which actually >>

Re: saving date/time when upgrades are applied?

2017-12-12 Thread Mike Bayer
There's an issue to add this at some point at https://bitbucket.org/zzzeek/alembic/issues/309/record-a-history-of-when-particular , however there's no timeline for this feature as I haven't had any time for new alembic features for some months now (contributions always welcome). basically the str

Re: alembic_version creation fails when in different new schema (Postgres)

2017-12-06 Thread Mike Bayer
On Wed, Dec 6, 2017 at 5:34 PM, Jules Olléon wrote: > Hello, > > I have an issue with schema creation when the alembic_version table is not > in the default (public) schema on Postgres. > > We have a setup where multiple services use the same Postgres DB (to > simplify ops work) but we are trying

Re: unit testing migration code

2017-12-01 Thread Mike Bayer
it's kind of a PITA but in Openstack we have fixtures which actually run all the alembic (or sqlalchemy-migrate) migrations on a new database. Some of the more ambitious projects even write unit tests in between each migration that use inspect() to check that the database state is what's expected.

  1   2   3   4   >