Closed Miguelreis closed 6 months ago
This proposal is interesting. However I don't understand how this library will benefit projects that use SqlLite locally. No commands will be generated so what is the point of using it?
You're correct, with this change this library will not generate its custom commands when making migrations based on a sqlite3 database, but that's important. The main point is that it should be possible to have this lib imported and still do migrations on an sqlite3.
The needs and motivated outlined in alternatives.md
, also apply for a sqlite3/postgres parallel development. Enum synchronization in a postgres environment still needs to be done.
this library helped me to easily:
however, since now I have a working migration I cannot generate new migrations based on sqlite3 (due to the error I mentioned in this issue's original text - the import from alembic_postgresql_enum import TableReference
as it triggers the alembic hook bindings starting from compare_enums
.
and now there's a few options:
from these options, number 3 i think is the preferred solution, so i created this issue.
with this change:
Good, I'll make this change
Very happy to hear that :)
when you have time, please also look into this quote of mine, as it would make the use of this lib as seamless as it is today but also for the my described use case, with backward compatibility aswell.
it would also be relevant that migrations created using this library would be applied only if upgrading a postgres database (my code above doesn't solve this issue).
if you need anything else i'll be available! Thank you.
There is new version 1.2.0a1
. Please check whether these changes fulfill your request. If everything is alright write back and full release will be dropped
Hi, Sorry for the delayed response. I can confirm that generating new migrations in 1.2.0a1
no longer breaks the existing workflow, and it shows the corresponding warning. Thanks.
any feedback on this?
it would also be relevant that migrations created using this library would be applied only if upgrading a postgres database (my code above doesn't solve this issue).
edit: i see you also changed in sync_enum_values. Dunno if its also usefull in other ops. thanks
edit: i see you also changed in sync_enum_values. Dunno if its also usefull in other ops. thanks
Sqlalchemy operations such as sa.Enum().create() will not do anything in dialects that do not have native enums
Hi, thanks for making your project opensource.
Problem
To my knowledge
alembic-postgresql-enum
assumes that migrations are being generated by postgres, and independently of the source database, it issues postgres-specific queries to check for existing enums.This is relevant specially for the common
SQLite
in development, andpostgres
in staging/production workflow, where currently this library is not able to fill the same needs as it does currently for a standard development inpostgres
from local/development to production.currently, using this library it is not possible to generate simple migrations on a
SQLite
, that is compatible both forSQLite
andPostgres
. Its also not possible to turn off the hooks todispatch_for("schema")
.e.g. what happens when trying to generate new migrations having previously imported
alembic-postgresql-enum
- fromalembic_postgresql_enum/compare_dispatch.py
. obviously this query is only valid for postgres.Proposed solution
As I understand it (after a quick look),
is the entrypoint for the other hooks to alembic to check enums and modify enums.
as a simple solution for this library to not be code breaking after import, is to add a check for the dialect, i.e.
defined_enums.py
.it would also be relevant that migrations created using this library would be applied only if upgrading a postgres database (my code above doesn't solve this issue).
Final Statements
if this is in the interest of the mantainers, i would make myself available to generate a pull request.
thanks for reading, and my apologies for any mistakes or if not relevant for you.