Hi,
I was wondering if I can get some pointers on how to do this. I want to copy data to an archive table before deleting the data. So let's say I have a model like below
class ModelA(...):
id = db.Column(db.Integer, primary_key=True)
fake_model_id = db.Column(db.Integer,db.ForeignKey('some_fake_model.id'))
...
fake = db.relationship('SomeFakeModel')
... For the archived class, do I need to include the relationship? The reason I ask is because I'm not sure how the relationship is populated via sqlalchemy.
So for the use case:
1. delete ModelA
2. restore ModelA
class ArchivedModelA(...):
id = db.Column(db.Integer, primary_key=True)
fake_model_id = db.Column(db.Integer,db.ForeignKey('some_fake_model.id'))
...
# no relationship here - is it needed?
...
To restore ModelA, I'd copy ArchivedModelA attributes to ModelA (e.g
https://stackoverflow.com/a/36225970) - but if ArchivedModelA doesn't have the "fake" relationship, is the new restored ModelA going to have the fake relationship via the foreign key? The
doesn't return the relationship.
Hope what I wrote makes sense!