Doctrine: Switch database first approach to code first approach - doctrine-orm

In the past, at our project it was decided to use Doctrine with "database first" approach and about 30 tables have already been processed.
We would like switch to the "code first" approach.
Is it possible to somehow build on already finished things or does the whole work have to start from scratch? How to proceed?
Thanks for the advice.

You probably want to generate Doctrine entities based on an existing database schema.
There is some support by Doctrine to do this which cannot handle every case but should get you started.
php doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml
For more information see e.g. documentation here

Related

zend framework 3 + doctrine 2 generate entities

How to configure ZF3 project to be able to use generate-entities command from Doctrine Orm Tools ?
I use Application\Entity namespace for the models, this tool generates entities in Application\Entity directory, not in Application\src\Entity dir.
How to tweak this?
You actually can't tweak this, the doctrine generator is only psr-0 and will not be updated (and will probably be removed in future versions). I do not have sources here, just stuff I reckon reading on the github project.
What you could do though is create a psr-0 loaded module, and change your config to use psr-0 just for your entities, but I would greatly recommend against it. If you want to go down that way, just update your composer autoload section to add your psr-0.
Your question is already answered here on stackoverflow. You have 2 options:
Option 1:
How to generate Doctrine entities From Database and Use PSR-4 Autoloading?
Option 2:
Just create the entities manually yourself. ( that’s what I do )
Good luck !

Doctrine DBAL get Server Information

I did not find anything about this in the manual of the Doctrine DBAL or the Search here.
So basically my question is, is there a way to get the Database Server Information using Doctrine DBAL.
PHP has things like "mysqli_get_server_info()" and "PDO::getAttribute(PDO::ATTR_SERVER_VERSION)", so I was looking if the Doctrine DBAL supports something like this as well.
An old question, but I needed an answer as well.
so:
$this->getDoctrine()->getConnection()->getWrappedConnection()->getServerVersion();

I've added a module in redmine, how can I enable it for many projects at once?

I've got all these great new plugins enabled, and I can enable them on any given project.
However, I don't see a way to add/remove them from many projects at once.
Perhaps I need a module management plugin? ;-)
In my case Redmine 3.1.0 and MySQL is used as DB server. I think, you'll get the main idea in case of other confuguration.
DELETE FROM `enabled_modules` WHERE `name` = 'module_name_here';
INSERT INTO `enabled_modules`
(`project_id`, `name`)
SELECT
`id`, 'module_name_here'
FROM
`projects`
You can activate module for one project to discover its name from enabled_modules. Or you can find it in plugin sources, it should look like 'project_module :module_name_here'
Please, don't do this if you do not completely understand, what is this answer about!
PS: Yes, I know - it is a dirty solution, but it's fast and easy enough for operation which is neccesary once a year or less.
It's been a while and I reckon the OP has since solved his problem. In case someone else has the same problem:
We also had to activate a few modules in all projects and wrote a small script to do it for us:
https://github.com/EugenMayer/enable_chiliproject_modules
Edit:
This was created and tested for the Redmine fork "Chiliproject" but should work without changes in Redmine.
how can I enable it many projects at once?
You can't - at least not by using the UI.

extension like django-evolution

I am in search for a extension that is similar to django_-volution.
The requirement is to alter the database, whitout deleting the wohle data.
I don't know, but for me, this is something so ordinary - doesn't django have a built-in function like that?
django_evolution is still in working progress and has some bugs, so i want something that is stable and maybe has more options. Especially to write own mutations seems a little bit complex for me.
Does anybody know something similar?
Thanks for all answers
You're looking for South. It's currently the de-facto schema and data migration plugin for Django. I believe there have been talks about adding it to the core of Django. It has a bit of a learning curve but you seriously want to take the time and learn it.
You'd like something to perform 'migrations' a la rails, correct? The best known and most stable project is South, as far as I know. It offers "intelligent schema and data migrations for Django projects".
http://south.aeracode.org/
Personally, I just alter my model, and make the changes through the database command line client.

Have you tried to use SQLite as the query engine for your *raw* database?

I have made a custom report generator for our database (Oracle Berkeley DB engine). Now it's time for me to add more flexibility and I am in dilemma. Do a partial or a fundamental redesign?
Lets assume that I have plenty of time.
I can only read the database, I don't have the right to modify it.
Inspired from Query Anything with SQLite article, I would like to let SQLite engine to do the dirty work (grouping, filtering, etc).
Have you tried it? Any examples? What about performance issues?
It works fine for what I am using it :-) However I don't use it together with another database, just standalone. There's a list of Well-known Users of SQlite on their website.
You need to tell us more about your usecase to make any speculations about performance, but I'd rather make a POC and measure performance Long-held, incorrect programming assumptions
There is a nice quickstart article on the sqlite site.
Here's the C/C++ API Reference.
I assume you should be able to create a temporary SQLite table by initially querying your other DB and inserting the data into the temporary SQLite table. Then you can use different querys on that temporary table to do your grouping, filtering, etc.