-
Notifications
You must be signed in to change notification settings - Fork 15
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
Migration - update schema -removing indexes #189
Comments
well, as of now, there's no easy way, unfortunately. Give me a couple of days to come up with something usable |
I have some ideas to try, I will push smth shortly |
pushed v 3.4.0, Look at test SchemaUpdate test, it creates extra index in migration; you just add the index name to ignore list - this is new thing, list of Db objects to ignore in schema upgrade; you can do it right in the RegisterMigr method where you add the script for the index. |
I upgraded VITa to 3.4.0 version, created new database and tried to update schema. I got an exception on the first run: The order in which the commands are executed appears to be incorrect because I believe that DbUpgrading event displays an ordered list of commands in the DbUpgradeEventArgs.UpdateInfo.AllScripts list. |
To the previous entry: When I applied the upgrade schema to an existing database I got exception but now related to the materialized view. The order in which the commands were executed was also incorrect. Here is order:
The question is, why is the materialized view always re-created? |
looking into this |
Looking at pg docs, trying to find this 'WITH NO DATA' clause, cannot find any: |
Here's the link I used as the source of my note:
https://www.postgresql.org/docs/current/sql-creatematerializedview.html
ut 21. 9. 2021 o 7:54 Roman Ivantsov ***@***.***> napísal(a):
… Looking at pg docs, trying to find this 'WITH NO DATA' clause, cannot find
any:
https://www.postgresql.org/docs/13/rules-materializedviews.html
what docs you use?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#189 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFOYASCSAG5QRNXLMUNCBXLUDAMZNANCNFSM5CY2YDSA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
ah, I see. But anyway, this With-Data clause is optional. I need no-data anyway because I need to wait for completion of all actions (just in case there are more keys and indexes, and tables must be finished etc) - before filling the data.
b) I do not have the 'old' view definition in db, notice I put empty string in the query for View_Definition field, so I have no way to compare the new vs old, so I assume I need to rebuild the views always. So the question is - do you really need that stuff? It seems gains/conveniences are marginal. If you do, the only way I see is create it and then add it to 'ignore' list |
Pushed new version; problem with indexes (wrong order) should be fixed. |
Thanks for the quick fix. The execution order is correct and the database
update works.
However, I still see the removal of clustered index in the materialized
view. I added a materialized view to the ignore list and it seems that it
remains intact but its cluster index is dropped and added even though I
added it to the ignore list too. But that is enough for me for now.
st 22. 9. 2021 o 7:47 Roman Ivantsov ***@***.***> napísal(a):
… Pushed new version; problem with indexes (wrong order) should be fixed.
For mat views, trying a workaround. Saving view SQL hashes in DbVersion
records (in DbInfoModule). Comparing hashes to figure out if views changed
or not.
Let me know if it works for you
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#189 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFOYASHRNVKVETRDLOUQ5WTUDFUWLANCNFSM5CY2YDSA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I forgot to say that the indexes added in the ignore list are really
ignored, only the index in the materialized view is re-created.
st 22. 9. 2021 o 7:47 Roman Ivantsov ***@***.***> napísal(a):
… Pushed new version; problem with indexes (wrong order) should be fixed.
For mat views, trying a workaround. Saving view SQL hashes in DbVersion
records (in DbInfoModule). Comparing hashes to figure out if views changed
or not.
Let me know if it works for you
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#189 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFOYASHRNVKVETRDLOUQ5WTUDFUWLANCNFSM5CY2YDSA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
will look into this index issue |
In 'EntityModule.RegisterMigrations' I create several GIST indexes (working with PostgreSQL) at the end of migration (AddPostUpgradeAction) by running an SQL script.
When I create database and apply a schema update, everything works as expected, but when migration is reapplied to the database, the GIST indexes are removed.
Upgrade options are set to 'DbUpgradeOptions.Default' only.
I use version 3.0.2 that VS package manager has shown me as latest stable.
So question is: How to avoid removing GIST indexes during a schema update?
Thank you in advance.
The text was updated successfully, but these errors were encountered: