Skip to content

Force recompile when migrations changed #681

Closed

Description

@dmarcuse

The migrate! macro is very handy right now, but it would be nice if it would also handle changes to the migrations - currently, the compiler will just ignore changes to these files when determining whether to use the cached build or not. Emitting const _: &[u8] = include_bytes!(...) for each migration should solve this.

Activity

  1. raftario commented on Sep 15, 2020

    @raftario
    Contributor

    The current behaviour was chosen to be consistent with the query_file! family. Emitting include_*! would also not solve the problem of cached builds with newly created migrations if I'm not mistaken.

  2. dmarcuse commented on Sep 15, 2020

    @dmarcuse
    ContributorAuthor

    Hmm, that is true, and I didn't realize that query_file also worked this way. I still think it would be worth having as an option, maybe as a feature flag.

    For now I've just been using a build script that walks the migrations directory and emits cargo:rerun-if-changed=... for each file, which works well enough.

  3. abonander commented on Apr 28, 2021

    @abonander
    Collaborator

    For modifying existing files, this should have the same solution as here: #663 (comment)

    However, picking up new files is another issue entirely, yeah.

  4. abonander commented on Apr 28, 2021

    @abonander
    Collaborator

    By the way, you don't need to manually walk the migrations/ directory, it looks like cargo:rerun-if-changed=migrations should suffice: https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorerun-if-changedpath

    If the path points to a directory, it will scan the entire directory for any modifications.

  5. abonander commented on Jul 14, 2021

    @abonander
    Collaborator

    A new API in proc_macro just recently hit nightly which would fix this: proc_macro::tracked_path::path().

  6. added 6 commits that reference this issue on Jul 20, 2021
    39124c5
    ee2b14e
    6fe2cca
    33c3ec4
    edb6b5f
    e1f9b51
  7. added a commit that references this issue on Jul 21, 2021
    e89cb09
  8. added 2 commits that reference this issue on Nov 19, 2021
    6cdb35d
    b5a95c4
  9. 5 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions