I don't have a lot of experience with these kind of issues, but I feel I need to consult on this issue. The current codebase I'm working on is using what I consider to be a questionable technique to reference entries in Database tables.
We have a system where for certain rows the value in that row is referenced with a const
in a format like const ID_ITEM_I_WANT = 1
and then to get the value of that row the query is made with the ORM to get the value.
My problem with this system is that if these tables are not static and can change. As well, it forces these tables to be manually assigned and updated in the seeders for the development environment and causes issues whenever they need to be changed. As well, if I want to add new entries I need to wait until the tables changes on the production server and then update the code and seeders to have a constant for whatever primary key has been assigned in production.
Is there a better way to handle these tables where I can lookup the values that are required from the DB, but not rely on any specific id
in the code. That way the seeders can have more arbitrary data and the code can be decoupled from the values in the production database.
types
and these consist of just anid
and aname
or similar. Because thename
is subject to change potentially it would be foolish to setconsts
to those, but theid
is fairly constant, so theid
is definitely better than thename
.seeder for the development environment
I mean a script which adds values to the local database used for development. Something like this: laravel.com/docs/5.7/seeding . Unfortunately the current design is making it difficult to do this.