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

Import data maintaining timestamps #481

Closed
ggtrigg opened this issue Jun 12, 2023 · 3 comments
Closed

Import data maintaining timestamps #481

ggtrigg opened this issue Jun 12, 2023 · 3 comments

Comments

@ggtrigg
Copy link

ggtrigg commented Jun 12, 2023

I'd like to be able to import data from another database and keep the created_at & updated_at times. From everythig I've tried it seems like granite always overrides these on create even if those values are explicitly provided.

@crimson-knight
Copy link
Member

You should be able to do bulk imports using import interface and not have it override the timestamps
https://github.com/amberframework/granite/blob/master/docs/imports.md

Did this also override your timestamps?

@ggtrigg
Copy link
Author

ggtrigg commented Jul 2, 2023

The import interface does override any supplied timestamps. I got around it by making a local modification so that the import only sets the timestamps unless created_at & updated_at are supplied. vis.

model.set_timestamps if (model.updated_at.nil? || model.created_at.nil?)

at

model.set_timestamps

If it helps I could raise a pull request with this change (and also for the other db adapters)?

@crimson-knight
Copy link
Member

@ggtrigg this is resolved with the new skip_timestamps option that can be passed in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants