AVideo-Encoder icon indicating copy to clipboard operation
AVideo-Encoder copied to clipboard

Change table configurations

Open trickert76 opened this issue 3 years ago • 8 comments

I try to install avideo and avideo-encoder inside a docker-compose environment together with a mysql server. I'd like to avoid using root for that database to setup two databases inside the mysql server. The only reason for that is, that avideo and avideo-encoder need to create some tables in their own schema/database.

But at the end both could store their tables inside the same database. Only the table configurations is a problem. It exists in both environments. If I can rename that table f.e. to "configuratations_encoder" then I could use the same credentials.

I would like to make a PR for that. Is the solution ok for you?

What is to do?

  • rename the table in install/database.sql
  • rename the insert statement in install/*.php, objects/functions.php, objects/Configuration.php
  • add a new update/updateDB.v3.9.sql with rename sql statement

Add the end - there is one problem. This is a breaking change. The current version of the app is stored in the table that is renamed, so the new Configuration object would look into a table that is not available in older version. I need to add there a hook to look for a table "configurations" or "configurations_encoder". That is a little bit ugly.

trickert76 avatar Feb 08 '22 07:02 trickert76

Hi,

Changing the configurations table will be a very big impact on the code. is not clear to me why can't have another database just for the encoder. so the configurations table may not be a problem

what other app do you have on the same docker image?

DanielnetoDotCom avatar Feb 08 '22 11:02 DanielnetoDotCom

First - you need root access or a user that is able to create databases. This is a very big issue in bigger environments where users/customers normally don't have such access rights to central infrastructure. Second - Because the application doesnt make sence without AVideo platform, there is a logic link between them and so there is no reason to use different databases for the same "service" from the infrastructure point of view. Also it is more complicated in case of backups/recovery etc. when there are several databases involved.

I'm not really sure, if this is really a big issue. At the end - especially this table is not really necessary, the information could also be stored in the configurations.php file itself. Using a database table for storing a single row is oversized.

trickert76 avatar Feb 08 '22 12:02 trickert76

I made a PR - please have a look.

trickert76 avatar Feb 08 '22 12:02 trickert76

I will look, but having a different DB for each service does not consume many resources.

anyway, I will review it.

also would be good to let you make multiple encoder installations. for example, use the composer to rise one streamer and 4 encoders. so you will need different databases for each encoder.

is it a big deal to do on the docker?

an alternative is to use a database prefix

DanielnetoDotCom avatar Feb 08 '22 12:02 DanielnetoDotCom

Of course a database prefix would be the best solution. And in docker it means, that you need to configure and use the root credentials. Of course that is easy, but it's the same with security and backup issues then. If you want prefixes, it could be, that I need your help a little bit more.

trickert76 avatar Feb 08 '22 13:02 trickert76

Question...

  1. So the idea is to use the same streamer database to host the encoder tables as well?
  2. how will you create the encoder tables on the docker?
  3. will you use the install/database.sql file to install?

DanielnetoDotCom avatar Feb 08 '22 13:02 DanielnetoDotCom

  1. yepp
  2. see 3.
  3. yepp. I'm running the install/checkConfiguration.php which itself creates the tables.

So if there is a new property f.e. "DB_MYSQL_PREFIX" I would forward it to checkConfiguration.php. Optional we could make same sed or change the Configuration::getTableName() function (and use it where possible like in the checkConfiguration.php or the update.php

trickert76 avatar Feb 08 '22 14:02 trickert76

This update should do the trick

now we have a variable called $global['tablesPrefix']

DanielnetoDotCom avatar Feb 08 '22 15:02 DanielnetoDotCom