Manage multiple databases and their migrations
Hi there,
Bit stuck on how to implement the next step of our application, a pointer in the right direction would be much appreciated.
The goal: Parsing json and trigger the creation/updates/deleting of tables . We should in the end have 1 laravel app for managing multiple databases.
The idea as if now:
project.yml
"db_info": {
"db_host": "xxx",
"db_user": "xxx",
"db_name": "xxx",
"db_password": "xxx"
},
"content": [{
"content_name": "blog",
"fields": [{
"name": "title",
"type": "text"
}, {
"name": "a_number",
"type": "int"
}]}
The code interprets the json-file and should build tables/columns customised to a project. (eg. a column named title in the blog table).
In another json file i would store the field types with default values:
{
"text": {
"autoIncrement": false,
"default": "",
"nullable": true,
"length": "255",
"type": "string"
},
"int":
.......
}
Combining those 2 files should create/delete/update tables or columns accordingly. Establishing the connection and creating the tables is already been sorted out.
The problem: Handling DB migrations for the tables.
- Should my code output some migration file and trigger a migration command? Thinking of the build-in migration tool in laravel or phinx for example.
- Should i make db-changes directly from my laravel app?
- ...any other route i could take?
As this project needs to scale, adding .env parameters and migration files seem tedious.
Please or to participate in this conversation.