Comments (4)
@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.
@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.
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.
@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)
- Support Django 4 HOT 4
- Fails to fetch model instances when model is restricted to primary keys of a related model. HOT 2
- Update primary key sequences after import HOT 1
- Document use of the testsite for manual testing
- Don't run by default in DEBUG=False
- Support running from an empty database without dropping/re-creating
- Displayed "host" for the database being dropped is misleading for remote databases
- Show progress within an importable model
- Simplify tox/GitHub Actions integration
- `django_db_blocker` doesn't seem to be doing anything
- Improve feedback when misconfiguring a strategy
- Drop legacy Python support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-devdata.