You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Connect a yii2 instance with a Microsoft SQL server (tested with mcr.microsoft.com/mssql/server:2022-latest docker image and msodbcsql18 unixOdbc drivers from Microsoft installed on the PHP instance). Create a view in a Microsoft SQL database with CREATE VIEW test AS SELECT 1 AS placeholder WHERE 1 = 0; within a migration. Run yii migrate/fresh.
What is the expected result?
All the tables and views in the database should be dropped and then recreated.
What do you get instead?
An error when the create view migration is executed after the database refresh.
Exception: SQLSTATE[42S01]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]There is already an object named 'test' in the database.
Additional info
The yii\console\controllers\MigrateController function isViewRelated only identifies drop view errors for SQLite and MySQL, which then causes the views to be ignored when the truncateDatabase function is executed. A Microsoft SQL specific condition should be added to the existing array to identify an error when using DROP TABLE on a view.
Q
A
Yii version
2.0.51
PHP version
8.3.8
Operating system
CentOS Stream 9
The text was updated successfully, but these errors were encountered:
What steps will reproduce the problem?
Connect a yii2 instance with a Microsoft SQL server (tested with mcr.microsoft.com/mssql/server:2022-latest docker image and msodbcsql18 unixOdbc drivers from Microsoft installed on the PHP instance). Create a view in a Microsoft SQL database with
CREATE VIEW test AS SELECT 1 AS placeholder WHERE 1 = 0;
within a migration. Run yii migrate/fresh.What is the expected result?
All the tables and views in the database should be dropped and then recreated.
What do you get instead?
An error when the create view migration is executed after the database refresh.
Exception: SQLSTATE[42S01]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]There is already an object named 'test' in the database.
Additional info
The yii\console\controllers\MigrateController function isViewRelated only identifies drop view errors for SQLite and MySQL, which then causes the views to be ignored when the truncateDatabase function is executed. A Microsoft SQL specific condition should be added to the existing array to identify an error when using
DROP TABLE
on a view.The text was updated successfully, but these errors were encountered: