db
db copied to clipboard
Add posibility to drop table `IF EXISTS` and `CASCADE`
Add two options for dropping a table
IF EXISTS- drop table only if it existsCASCADE- drop also dependencies cascade
Suggestions for QueryBuilderInterface::dropTable()
- Change argument
string $tabletoarray|string $tablesand realize method for list of tables; - Add second argument
$cascade = falseand generate SQL query to drop tables and dependencies cascade; - Add new method
QueryBuilderInterface::dropTableIfExists()with the same agruments and generate SQL query withIF EXISTSconstruction.
MSSQL is not supported CASCADE option: https://learn.microsoft.com/sql/t-sql/statements/drop-table-transact-sql?view=sql-server-ver16
Should we throw exception when $cascade is true in MSSQL? Or we need to use tricks, for example: https://stackoverflow.com/a/4858773?
In cases when DBMS does not support functionality we use complex queries like https://github.com/yiisoft/db-mssql/blob/eb4e5ef9eb7de1fb340b9c4bb894f921d4cad882/src/DDLQueryBuilder.php#L237