CodeIgniter Forums
Automatic Database Migrations - Proposal - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: Automatic Database Migrations - Proposal (/thread-74840.html)



Automatic Database Migrations - Proposal - loopzzz - 11-14-2019

Hello community, 
i had a few projects in Python/DJANGO and have seen some really useful stuff but one especially helpful

Database migrations generated automatically from the Models

i love CI and want to have all the good stuff in here as well to speed up development times

Benefits:

- table field definitions are in a single place (single source of truth) in the Model
- migration files are temporary
- you can delete all dev incremental migrations and recreate a final migration

i understand that this is a braking change for the CI updates but that's why i ask your opinions on this.

Implementation:
we already have the $allowedFields property defining the field names

i propose new property called $fields or similar describing the fields like in the migrations currently, this also needs clarification.

What are your thoughts ?


RE: Automatic Database Migrations - Proposal - MGatner - 11-14-2019

I have a module that plans to include this:

https://GitHub.com/tattersoftware/codeigniter4-schemas

The Publisher handlers aren’t written yet but the Model Drafter is there. I have to peel for another project but hopefully will be looking at Publisher soon.


RE: Automatic Database Migrations - Proposal - loopzzz - 11-14-2019

Thanks @MGatner but from what i saw your library is doing schema generation from existing Database.
what i would like to have or make is

Model ----> migrations ----> database <---- Seeds (fixtures)


so that the schema definition is in one place and thats the Model

whats your recommendation for this, i understand that you have lots of experience on this already and i don't want to reinvent the wheel.


RE: Automatic Database Migrations - Proposal - MGatner - 11-15-2019

Yep. I understood, and it is planned but not coded yet.