D
D
Dmitry Kim2016-06-03 12:56:50
Yii
Dmitry Kim, 2016-06-03 12:56:50

What database structure to choose for two identical sites in Yii2?

It is necessary to update two logically identical sites written on the knee in 2009.
Both sites are owned by the same owner. He wished that the design and logic were again the same in order to keep the "similarity" of the sites.
One template was selected for development Yii2-advanced. Sites are built on a modular system, all modules (controllers, models, views, traits, interfaces, widgets and behaviors) are stored in common, widgets, helpers, etc. are also located there. In the site location folders, only folders configand web. Only small differences between projects remained in the config folder - id and project names, admin emails, etc.
At this stage, almost all the logic of work has been created, tables in the form are used in queries {{%news}}, the database is specified in common/config/main-local.php.
Now the main question:
How to deal with the database?

  1. Make two identical bases
  2. Make one database, and in it there are two identical tables of each destination
  3. Make one database, one table for each destination, and create a field for the record belonging to the project - 0/1

It would be logical to choose the second option. In this case, is it possible to specify the database connection in common/config/main-local.php, and specify the table prefixes in the configs of each site? And the second question: how to deal with consoleand migrations? After all, as far as I understand, migrations do not use prefixes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2016-06-03
@kimono

After some discussion, the first option was chosen as the optimal solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question