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

Converting existing model to Smart model #10

Open
deiucanta opened this issue Aug 28, 2018 · 5 comments
Open

Converting existing model to Smart model #10

deiucanta opened this issue Aug 28, 2018 · 5 comments

Comments

@deiucanta
Copy link
Owner

Let's say you have the user model already. The migration is there and the database is up to date. You want to use Smart model from now on.

Converting the model will generate a new migration as if nothing was in the database. This happens because we didn't track previous states of the user model.

If we add a command that doesn't generate a new migration but updates the smart.json file, I think we should be good on this issue.

Am I missing anything?

@robsontenorio
Copy link
Collaborator

robsontenorio commented Aug 28, 2018

I consider this can messup things , because is dangerous.

I do prefer convert the project into smart models, delete all migrations file and generate then again with Smart.

@deiucanta
Copy link
Owner Author

@robsontenorio I know you are converting an existing project to use this package. Let us know how it goes.

Meanwhile, a few questions

  • how will you handle the migrations that are generated by 3rd party packages (laravel cache table, queue failed jobs table, password resets table)?
  • when you create a new laravel project you get 2 migrations by default (users and password_resets if I'm not mistaken) - do you delete them and recreate them via smart models?

There are two cases we need to support

  • existing migrations with app models
  • existing migrations from external packages

@robsontenorio
Copy link
Collaborator

robsontenorio commented Aug 28, 2018

Just finished the project migration. It took about 1h with 25 models.

  • Modify models to extends from Smart Models, except User model. Because it already extends Authenticate model.
  • Keep all 3rd party migrations, including user Model.
  • Drop all another app migrations
  • php artisan smart:migration

The process was smooth due to app automatic tests.

@deiucanta
Copy link
Owner Author

@robsontenorio 1h is pretty good!

  • did you feel the API is lacking fluency beside the timestamps fields?
  • are you fine leaving the User model as is?
  • is it a REST API or a full-stack app?

@robsontenorio
Copy link
Collaborator

  • Yes, I miss short handy timestamp() statement.
  • Yes, I dont touch User model. For now, i don`t have a solution.
  • Laravel REST API only

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