-
-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB Driver migration - SQL Server 2012 #215
Comments
I reviewed the DB driver migrations and merged into one for a work around. |
Migration can not be combined. It breaks extension updating. |
It is from ../src/drivers/db/migrations/M...Priority.php:
|
The migration includes |
I don't have experience with mssql. I need more info about. |
I am not well versed in MSSQL inner component handling, but from what I am able to discern is that tables will create a constraint object that defines anything from column definitions such as NOT NULL to indices. Therefore, it appears the index must be removed prior to column rollback. This will appear under the table's Constraints folder within MS SQL Studio. See below... [Edited: add more detailed screenshots] |
SQL Server Developer Edition can be downloaded for free here. |
In MSSQL when we use Because the name is autogenerated, you should find the name it db sys table. To do that, I added a method in our Migration base: /**
* Builds and executes a SQL statement for dropping a column default constraint.
*
* @param string $table the table whose column is to be altered. The name will be properly quoted by the method.
* @param string $column the name of the column to be altered. The name will be properly quoted by the method.
*/
public function dropDefaultConstraint($table, $column)
{
echo " > drop default value constraint for column $column from table $table ...";
$time = microtime(true);
$constraint = (new Query())
->select(['default_constraints.name'])
->from('sys.default_constraints')
->innerJoin('sys.all_columns', 'default_constraints.object_id = all_columns.default_object_id')
->innerJoin('sys.tables', 'tables.object_id = all_columns.object_id')
->innerJoin('sys.schemas', 'schemas.schema_id = tables.schema_id')
->where(
[
'AND',
['schemas.name' => 'dbo'],
['tables.name' => $this->db->schema->getRawTableName($table)],
['all_columns.name' => $column],
]
)
->scalar($this->db);
if (!empty($constraint)) {
$this->db->createCommand()->dropForeignKey($constraint, $table)->execute();
}
echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n";
} |
I have been able to consistently reproduce this error within SQL Server 2012.
Steps:
The text was updated successfully, but these errors were encountered: