Using Governance to deploy new contracts

I'm setting up a DAO-style environment for users to hold tokens and propose/vote on proposals to control various aspects of the ecosystem. One way to introduce new features is by voting on the deployment and implementation of new contracts. For example, we may wish to implement a new type of pricing oracle which we might introduce through a proxy contract.

My question is, am I able to introduce features through new contracts and can these new contracts be deployed via executing successful proposals? My plan was to build a contract with new features, propose it using create2 to determine the address, and, if successful, deploy the contract before executing the proposal. Alternatively, (if I can work out how to do it), it would be even better to have some kind of deployer that will deploy the new contract as part of the proposal.

I'm wondering if 1) my plan is feasible, and/or, 2) if there is a more elegant way to achieve this.

Thanks for any insight.

You can deploy a factory contract that has a create() function that does new Foo(), and then propose to the DAO to invoke create() on the factory.

Thanks for the reply. One thing I don't understand about this design pattern is that I would need to deploy a Factory contract in order to deploy the intended contract so I end up having to deploy something before creating the proposal.

So my workflow looks something like this:

  1. I have a governance contract which can deploy other, new contracts if a vote is successful,
  2. I don't want to actually deploy any contract before a successful proposal has been executed. In fact, the execution of the proposal will be the contract creation event,
  3. Upon execution, the contract is successfully deployed by governance and is initialized for use.

If I require a Factory contract, doesn't this negate the benefits of 2 and 3? I.e. Why not just go ahead and deploy the actual contract directly then vote on some kind of initialize function?

That sounds great as well!