Skip to content
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

.transform() effect on triggers and indices #611

Open
vkz opened this issue Jan 20, 2024 · 0 comments
Open

.transform() effect on triggers and indices #611

vkz opened this issue Jan 20, 2024 · 0 comments

Comments

@vkz
Copy link

vkz commented Jan 20, 2024

Could you clarify and expand what the upgrade verb in the following statement from Custom transformations with .transform_sql means, please?

The .transform() method can handle most cases, but it does not automatically upgrade indexes, views or triggers associated with the table that is being transformed.

I make heavy use of triggers and consider using sqlite-utils for migrations, so understanding exactly what happens to my triggers is kind of important. Are we talking about cases where, say I rename a column which a trigger relied upon? E.g. in the following example:

CREATE TRIGGER IF NOT EXISTS insert_lang_on_thread_subject AFTER UPDATE OF subject ON thread
WHEN NEW.subject IN (6, 7)
BEGIN
   ...
END

any changes to the thread table, like, say renaming subject field won't be reflected in this trigger? Is this what the won't upgrade above mean?

IIUC the proposed remedy is to grab the sql code for changes from .transfor_sql() and for this particular example, I guess, add a statement that drops the trigger and creates a new one with correct references to tables and columns?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant