craue / CraueConfigBundle

Database-stored settings made available via a service for your Symfony project.
MIT License
173 stars 35 forks source link

Prevent default craue_config_setting table from being created #36

Closed crmpicco closed 5 years ago

crmpicco commented 7 years ago

Is there a way to prevent the default craue_config_setting table from being created when running a doctrine:migrations:diff?

I can create a custom entity in my application by doing this: https://github.com/craue/CraueConfigBundle#using-a-custom-entity-for-settings

...however although it produces the config_setting custom table, it also includes the craue_config_setting table too - which I don't need.

$this->addSql('CREATE TABLE config_setting (name VARCHAR(255) NOT NULL, section VARCHAR(255) DEFAULT NULL, value TEXT DEFAULT NULL, comment VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name))');
$this->addSql('CREATE TABLE craue_config_setting (name VARCHAR(255) NOT NULL, section VARCHAR(255) DEFAULT NULL, value VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name))');
crmpicco commented 7 years ago

@craue I believe I have a solution to prevent this table from being created. Would you be interested in me submitting a pull request for this?

craue commented 7 years ago

Sure.

pitpit commented 7 years ago

+1 interested too

craue commented 7 years ago

@crmpicco, any progress?

laupiFrpar commented 6 years ago

I find a solution. You can configure doctrine/dbal to ignore those tables.

doctrine:
    dbal:
        [...]
        schema_filter: ~^(?!craue_config_setting)~

Source : Symfony - Documentation - DoctrineMigrationsBundle

yvoloshin commented 6 years ago

I have a couple of follow-up question on this issue. I too would prefer that my custom settings entity table is created without the craue_config_setting table, but creating this table is not a problem as long as I can be sure that it is not used. So far, during my tests all the settings data is saved in the custom settings table. Are there any circumstances when data would be saved in the craue_config_setting table?

Also, could you explain why the craue_config_setting table gets created in the first place, and how inheritance is set up? Since the custom settings table uses fields in the craue_config_setting table, this looks like a case of Single Table Inheritance. But doesn't quite make sense because the BaseSetting parent class doesn't have @InheritanceType("SINGLE_TABLE") annotation. Any help is greatly appreciated.

j0k3r commented 5 years ago

@crmpicco any progress on the PR?

mboron83 commented 5 years ago

@craue have you found any solution to prevent craue_config_setting from being created while custom settings entity is enabled?

crmpicco commented 5 years ago

@j0k3r @craue Apologies, I never got around to finding a suitable solution for this. My "solution" was to delete the doctrine-mapping/Setting.orm.xml file from disk which prevented the craue_config_setting table from being created.

I have my own table, called config_setting and if there was a way to configure the bundle to use that then I wouldn't have needed to be marooned on an old commit.

I have now picked this back up because I have upgraded Twig locally and the CraueConfigBundle commit I am on is using a deprecated function.

Is there a way to customise the table name or ignore the Setting.orm.xml file entirely?

I think in the meantime I will need to fork this project and delete the doctrine mapping file and sync with upstream changes, but i'd rather use the parent project correct and not have to maintain a fork.

Do you have any advice?

craue commented 5 years ago

Hey guys. Take a look at #50 and let me know if it works for you. Feedback is welcome.