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

Support different reset modes during import #26

Merged
merged 17 commits into from
Jan 8, 2024

Commits on Dec 11, 2023

  1. Introduce the idea of different modes to clear the database before im…

    …port
    
    Currently the only mode is the existing behaviour, however this
    opens the door to other approaches.
    PeterJCLaw committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    d79475c View commit details
    Browse the repository at this point in the history
  2. Allow users to opt-out from resetting the database

    This is unlikely to be common, however it provides an escape hatch
    for advanced users who want to do their own thing.
    PeterJCLaw committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    765c6f8 View commit details
    Browse the repository at this point in the history
  3. Validate all reset modes when testing imports

    This is slightly wassteful, but should mean we cheaply get good
    coverage over all the interesting model relations we come up with.
    PeterJCLaw committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    c555467 View commit details
    Browse the repository at this point in the history
  4. Ensure that Postgres sequence import works with the 'none' reset mode

    Sequences don't nicely fit into one of just schema or data, they're
    somewhat inherently both. Given that Django's "loaddata" over-writes
    existing rows in tables, it seems reasonable to do something similar
    for sequences -- even if that means we actually drop the sequence
    and fully re-create it.
    PeterJCLaw committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    f058c73 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fb9cec6 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    78f06a3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f06dd84 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    87566b2 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b94d9df View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2023

  1. Remove redundant migrations dumping

    This happens in self.dump_data_for_import, likely I missed this in 78f06a3.
    PeterJCLaw committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    b8d61fa View commit details
    Browse the repository at this point in the history
  2. Ensure Django's migrations table is consistently present

    This introduces a util to simplify this and adds usage to a couple
    of places which had been missed.
    PeterJCLaw committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    05da3db View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e7e3f20 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4227139 View commit details
    Browse the repository at this point in the history
  5. Demonstrate the result of reset-mode none over existing data

    Essentially we get a merging of the two sources of data.
    PeterJCLaw committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    7d50fbd View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    219e810 View commit details
    Browse the repository at this point in the history
  7. Always confirm imports

    Importing, even in the 'none' case, is potentially destructive so
    we want to give the user a chance to bail.
    PeterJCLaw committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    3ad2e85 View commit details
    Browse the repository at this point in the history
  8. Improve documentation on how the reset modes behave

    Also includes docs for the Postgres sequences extra.
    PeterJCLaw committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    729a19f View commit details
    Browse the repository at this point in the history