Skip to content

.transform() effect on triggers and indices #611

Open
@vkz

Description

@vkz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions