symfony icon indicating copy to clipboard operation
symfony copied to clipboard

Doctrine integration

Open sagikazarmark opened this issue 8 years ago • 3 comments

I haven't found any previous discussions about this topic, so I start one here:

One thing that is missing from this gem (and we had it in capifony) is doctrine integration.

I have this basic list of doctrine tasks:

namespace :doctrine do
    namespace :schema do
        desc "Drop doctrine schema"
        task :drop do
            on roles(:app) do
                invoke "symfony:console", "doctrine:schema:drop", "--force"
            end
        end

        desc "Create doctrine schema"
        task :create do
            on roles(:app) do
                invoke "symfony:console", "doctrine:schema:create"
            end
        end
    end

    namespace :migrations do
        desc "Execute doctrine migrations"
        task :migrate do
            on roles(:app) do
                invoke "symfony:console", "doctrine:migrations:migrate", "--no-interaction"
            end
        end
    end

    namespace :fixtures do
        desc "Load doctrine fixtures"
        task :load do
            on roles(:app) do
                invoke "symfony:console", "doctrine:fixtures:load", "--no-interaction"
            end
        end
    end
end

I am aware of https://github.com/glooby/capistrano-symfony-doctrine, but I think it would be better to have it in the symfony package. Also, I propose the following improvements:

  • Support different entity managers
  • Roles and environment should be defined by the user when using the specific tasks in the configuration

What do you think?

sagikazarmark avatar Mar 18 '16 11:03 sagikazarmark

hi @sagikazarmark.

I would rather keep this logic in the separate library, I would generally not recommend running anything other than migrations:migrate (and perhaps database:create) in a production environment. These commands end up being quite specific to each team's workflow.

If people are finding the doctrine library useful then perhaps we can add a link to the README?

peterjmit avatar Mar 19 '16 12:03 peterjmit

Well, to be honest I had doubts as well about this.

One point though: doctrine commands, like drop, fixtures might make sense in dev env.

Let's see if I can come up with something.

sagikazarmark avatar Mar 19 '16 18:03 sagikazarmark

I will add the migrate command to the documentation.

Nyholm avatar Sep 06 '18 21:09 Nyholm