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

How to create the first version of a model in an existing project? #73

Open
ricardogffcouto opened this issue Oct 9, 2020 · 6 comments

Comments

@ricardogffcouto
Copy link

Hello! I am adding versionable to an existing project, with a pre-filled database. I want the current values to be the first versions of each object. How can I accomplish that?
Thanks!

@nonoesp
Copy link
Collaborator

nonoesp commented Oct 9, 2020

I don't think that's supported. You could do a minimal update to your model to force a version to be created.

https://github.com/mpociot/versionable/blob/master/src/Mpociot/Versionable/VersionableTrait.php#L163

This method only runs after saving (on first creation or update) but I haven't found a way to force create a version.

Seems like a good thing to add to the package.

@DerekBuntin
Copy link

This works fine for me.

I firstly created a new article and that first version was successfully saved.

I then edited an existing article and that was also successfully saved.

What you need to do is open the item or article in my case and save it with no changes, it'll save that version for you.

@nonoesp
Copy link
Collaborator

nonoesp commented Oct 19, 2021

Hi, @DerekBuntin, thanks for your comment! I believe @ricardogffcouto was talking about creating a version from pre-existing elements, not newly created articles/items. 🙂

@DerekBuntin
Copy link

Hi, @DerekBuntin, thanks for your comment! I believe @ricardogffcouto was talking about creating a version from pre-existing elements, not newly created articles/items. 🙂

Hi @nonoesp, yeah I also just opened an already created row, one that existed before integrating the package, opened it and then saved it successfully.

@nonoesp
Copy link
Collaborator

nonoesp commented Oct 19, 2021

Hi @nonoesp, yeah I also just opened an already created row, one that existed before integrating the package, opened it and then saved it successfully.

I see. Thanks for testing then! I'll give it a try. =)

@jayenne
Copy link

jayenne commented Mar 2, 2022

As it seems to be a one time only function, I guess you could write a command to loop (chunk) touching all models

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

4 participants