-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot update view #4
Comments
Could you please provide:
by "exact definition used for XXX PGView" I mean my_view = PGView(
schema='public',
signature='user_display',
definition="""
SELECT
u.rowid,
u.email,
u.created_at,
u.deleted_at
FROM
users u
"""
) |
Thanks for the quick response. First the versions: Initial view:
Updated view:
My env.py:
|
Thank you, I was able to reproduce the problem. The issue is that once the view is created in the database, it is retrieved with the schema name I will fix this in a next release within a few days. You can avoid this problem for now by replacing |
Thanks very much! I changed from "PUBLIC" to "public" and the view update was reflected by alembic by replacing the view, works now. I'll upgrade to the new version when I see it. Thanks again, this will make a difference to our dev process. |
Thought about this a little more The error you experienced is small edge of a much larger problem where is that any schema, view, or function names containing an uppercase character will be incorrectly handled. One issue with the "easy fix" of changing the equality checks to be case insensitive is that it prevents a valid usecase where casing is the only difference between two schema names (or view/function names) For example, this is valid (although probably not a good idea) create schema dev;
create schema "DEV"; To support that, schema names and names defined in the signature blocks are treated as case sensitive in That means your example would still fail, but it would have failed when you first tried to create the view with an error To be clear, that means you will still need to use |
v2.6 is out |
I rediscovered an unpleasant memory in preparing to retest with v2.6. Dropping a column from a view cannot be handled using "create or replace", which returns "ERROR: cannot drop columns from view", Postgres docs confirm this, and "alter view" doesn't do it either. It appears the concern is breaking other views that could depend on the soon-to-be-dropped column (good), even if there are none (bad). Dropping the view and then dispatching "create or replace" works. If there is a dependent view, the drop will fail, telling you what depends on the view (good). So it seems that in order for view migrations to work in both directions, "create or replace view" must first drop the view in question. That will fail with a sensible message if there are dependent views and succeed otherwise. Would it be possible to generate upgrades and downgrades that way, first dropping then creating or replacing? |
Feel free to re-open this issue if you feel the original question wasn't resolved. |
Hi,
I am new to Alembic but seem to be able to use it, so far.
No problem getting the first migration for creating the view, ran update to head and it was created, no problems.
When I added one field to the view and autogenerated a new migration was created, but it appears to creating/dropping instead of replacing:
Any ideas?
The text was updated successfully, but these errors were encountered: