Git Product home page Git Product logo

Comments (4)

PeterJCLaw avatar PeterJCLaw commented on May 14, 2024

@danpalmer just wondered if you had any thoughts on how to approach this? I'd be interested in picking this up at some point, but might be useful to have some pointers towards why this limitation exists/what's already been explored/what you think might be needed here.

from django-devdata.

danpalmer avatar danpalmer commented on May 14, 2024

@PeterJCLaw this was definitely skipped due to lack of immediate need (at the time) and the fact that they're not represented in Django's models.

As the models are devdata's source of truth there isn't a convenient equivalent to hang the sequences support off. However, because they're simpler we should be able to just always insert them all at the beginning.

Perhaps we could start with:

  • Introducing a Sequence strategy class
    • Adding some initial utility implementations with extraction and/or hard-coded start/stop/current value/etc.
  • Adding a sequence strategies setting, distinct from the model based strategies.
  • Iterating through each during export
  • Iterating through each during import and adding to the database before model strategies.

There shouldn't be any interdependencies I don't think so hopefully these should be much simpler than the model equivalents.

What do you think? It's been a while since I've looked at the codebase so I could be a little off on the pieces required.

from django-devdata.

PeterJCLaw avatar PeterJCLaw commented on May 14, 2024

Having a look at this this evening and it looks like the current Strategy & Exportable classes are (as you say) based around the expectation that there's a model for everything. One option might be to have sequences handled by a different hierarchy of mixins which don't have that limitation (likely we could pull out some common logic though); not sure if that's what you had in mind.

Something else we'll need to think about is how to know which sequences to export. Obviously requiring users to list them manually would work, though doesn't feel ideal. However auto-detecting them would likely require a mechanism to filter out those which are attached to fields (and would thus be created by the schema import).

An idea therefore might be to allow devdata to run against an existing empty database so that users can do their own schema export/import if they want to (which would include sequences, at least on Postgres), sidestepping the need to support them directly. I realise that doesn't fully solve this issue though.

from django-devdata.

PeterJCLaw avatar PeterJCLaw commented on May 14, 2024

@danpalmer I've ended up going in a slightly different direction here. In #12 I've introduced the idea of "extra" strategies which aren't tied to database models and then implemented sequence export/import within that framework. (In theory I think the Django migrations table export could also fit into that framework, though I've not explored that). Would be good to get your thoughts on that approach.

from django-devdata.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.