Replies: 2 comments 1 reply
-
Hello. |
Beta Was this translation helpful? Give feedback.
-
Hello, I was planning to build something similar to Prisma ORM—or you could say it's along the lines of Symfony's approach—where we simply define the data source, and the system reflects those definitions into the database. The idea is to track database changes using the information_schema tables. Then, whenever we run a command like db:update, it would scan the current database schema, compare it with the model definitions, and generate the necessary queries to synchronize the database with the defined structure. For defining the database schema, we’d use a property-based model, where we list all columns, their data types, and attributes—similar to how we make migrations. |
Beta Was this translation helpful? Give feedback.
-
Hello Artisans,
I've been working with various ORMs and noticed that JavaScript-based ORMs like Prisma and Sequelize conveniently follow a concept called "schema" or "data source." This approach simplifies database management by automatically reflecting schema changes in the database structure. I believe incorporating a similar feature into Eloquent ORM could be highly beneficial.
Proposed Feature: Schema-Based Table Management in Eloquent
Instead of removing migrations, I suggest adding an additional feature to Eloquent ORM that enhances how we define and manage database schemas.
Rather than replacing migrations, this feature would serve as an enhancement to existing Eloquent models.
Just like standard models, these enhanced models would function similarly but with an added capability.
A new property, similar to $fillable or $casts, called $schema, would allow developers to define table structures directly within models.
Additional Artisan commands could be introduced to streamline database updates:
php artisan db:create
– Creates a new database or updates the existing one, applying migrations automatically based on the .env configuration.php artisan db:generate
– Updates tables and their schema definitions efficiently.I believe this feature could greatly improve database management in Laravel, making schema changes more seamless and intuitive. What do you all think?
Beta Was this translation helpful? Give feedback.
All reactions