Home yii2 Alter Table Yii2 Migrate

Alter Table Yii2 Migrate

Author

Date

Category

Tell me, pliz, like on Yii (in migration)
Rename the table.
Is there a built-in method,
or you need to do through the sql
such as such

\ yii :: $ app- & gt; db- & gt; createcommand ('Alter Table Newsletter Rename to Mail') - & gt ; execute ();

But I would like to know if there is a built-in method?


Answer 1, Authority 100%

There is a method for changing the title table. But I would like to warn from some incidents at once. It is recommended not to rename the table, but create a new and work with a new table instead of the old. This is done in order if you suddenly have to roll back the code changes, then there will be no errors of working with the database. The meaning is that the database structure must correspond to a new release and old. So there will be fewer problems on production. And in the next release you can already delete the old table.

$ this- & gt; renametable ('table_name', 'new_table_name');

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions