Is your feature request related to a problem? Please describe.
The sqloquent make migration --model ... CLI command currently creates a create table migration by parsing the columns attribute of a model and the type annotations. But if the model schema needs to be changed, this will not work because the table already exists. In such cases, the best option is to use a simpler migration generator, e.g. sqloquent make migration --alter ....
Describe the solution you'd like
Update the make migration --model command to attempt to read the current schema from the database for the table, compute the difference between the current schema and the desired schema encoded in the model class, and produce an alter table migration that drops/adds columns as appropriate in both the up and down functions.
Describe alternatives you've considered
Not adding the feature, but I kinda want it.
Additional context
Not a high priority since it is already possible to do this manually.
Is your feature request related to a problem? Please describe.
The
sqloquent make migration --model ...
CLI command currently creates acreate table
migration by parsing the columns attribute of a model and the type annotations. But if the model schema needs to be changed, this will not work because the table already exists. In such cases, the best option is to use a simpler migration generator, e.g.sqloquent make migration --alter ...
.Describe the solution you'd like
Update the
make migration --model
command to attempt to read the current schema from the database for the table, compute the difference between the current schema and the desired schema encoded in the model class, and produce analter table
migration that drops/adds columns as appropriate in both theup
anddown
functions.Describe alternatives you've considered
Not adding the feature, but I kinda want it.
Additional context
Not a high priority since it is already possible to do this manually.