Open BladeRavinger opened 5 years ago
Hi, can you please help to clearify what kind of feature you're proposing in this issue? I don't really understand your description.
As far as I can read, it is about not purging tables, but only for some table rows and not the whole table data?
Sorry i was not clear.
I propose that only tables that the developer has created fixtures for be purged instead of the whole database.
Example. I have database with 5 tables, 2 of those table i manage manually for User/Role management. the other 3 tables are for Posts/Comments/Tags.
I have created a fixtures file and im making changes to Post/Comments/Tags Fixtures knows this as it has the use
statements for these entity's. Fixtures should read that i only want to make changes to these 3 tables. purge them and leave User/Roles unaffected.
i use fixtures often, every time i generate a new migration that adds a field to my tables i update fixtures and load it. in the current state this means i have to either dump the Users table and then import it after the load. or recreate the user each time. i know i could just create a user fixture and insert the same user every time. but that not ideal.
My point is also here.
If I use --group={SOME_GROUP}
and --purge-with-truncate
options at the same time, I would like only tables in specified SOME_GROUP to be truncated.
BTW, class Doctrine\Common\DataFixtures\Purger\ORMPurger
has 2nd parameter as array with excluded tables.
My point is also here. If I use
--group={SOME_GROUP}
and--purge-with-truncate
options at the same time, I would like only tables in specified SOME_GROUP to be truncated.
i did not realize this was an option, i will give it a try. either my understanding of the documentation is lacking or more details could be added?
sorry im a little retarded so i have great difficulty interpreting most documentation
My point is also here. If I use
--group={SOME_GROUP}
and--purge-with-truncate
options at the same time, I would like only tables in specified SOME_GROUP to be truncated.i did not realize this was an option, i will give it a try. either my understanding of the documentation is lacking or more details could be added?
sorry im a little retarded so i have great difficulty interpreting most documentation
there is an option to separate fixtures by groups, but if you use purge option, all the tables will be truncated. I just wrote an suggestion.
i saw thank you. this will allow me to do what i want. i appreciate your input
Purging only tables based on the fixture classes is going to be difficult: there’s nothing stopping you from creating multiple different entities in a single fixture class, so the library can’t really know what to clear based on the class.
I’m moving this issue to the data-fixtures project, as this is nothing that should be solved in the bundle, but rather in the underlying library.
Purging only tables based on the fixture classes is going to be difficult: there’s nothing stopping you from creating multiple different entities in a single fixture class, so the library can’t really know what to clear based on the class.
I’m moving this issue to the data-fixtures project, as this is nothing that should be solved in the bundle, but rather in the underlying library.
Maybe the following idea could be fixable - to add new option -exclude="table1, table2, ..."
to prevent some tables to be truncated...
Perhaps the fact that in the fixture class we use App\Entity\Foo;
don't affect tables that are not used?
obviously if you try to make changes without a use statement you get errors
so as its a thing that will exist, and must exist, can we not look for use App/Entity/*
and drop or truncate these automatically. i havent a clue if this is even possible, but as a default behavior that in itself makes sense.
thats just my 10cent.
i thank you all for the help.
Note that currently the purger has no idea of what you’re doing in your fixtures. I’m not saying it’s impossible, but it’s also not something that we can just fix. It definitely requires some thinking as to how to accomplish it.
Note that currently the purger has no idea of what you’re doing in your fixtures. I’m not saying it’s impossible, but it’s also not something that we can just fix. It definitely requires some thinking as to how to accomplish it.
of course, being a sub par coder myself i understand this, so the idea is here if you guys ever choose to work on it. im not pushing you to go make the change. Thewind1984 gave me a solution that will work for what i want, but the suggestion still stands if you guys choose to incorporate it in the future
This is not the first time I would like to have a feature like the one describe here.
A common use, is when you have a table for statuses of another table (like "Project" and "ProjectStatus"). In my case, ProjectStatus can't be added using the app. So to manage those statuses, I use Fixtures.
When pushing in prod, I need to update the prod ProjectStatus in database values but I just can't load the ProjectStatusFixtures beacause the only two options are :
A solution could be an interface Doctrine\DataFixtures\TableRelatedFixtureInterface
with a method public static function getTables(): array
.
When implementing the interface, the developer needs to define that method to give the information of which tables are affected by the fixture (and should be purged)
And option like --purge-only-related-tables
will make the purger to check the getTables()
of each Fixtures file.
So im obviously working on my website and for back end trial and error junk i require user logins to get at admin sections for reasons. it would be nice if instead of a database purge, wiping my 3 users of various permission levels, it would only drop/create tables that fixtures will be working on, as at present i am not creating dummy user data and its a pain to recreate the users each time i reload fixtures.