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
CakePHP Version: 3.7.9 (but version should not be relevant)
Bake plugin version (if relevant): 1.10.1 (but version should not be relevant)
Database server : MS SQL Server 2017 (but version should not be relevant)
PHP Version: 7.1.7 (but version should not be relevant)
Platform / OS: Windows 7 (but version should not be relevant)
What you did
I have created a table in a database on a MS SQL Server in a schema other than the default one dbo, e.g. [my_database].[custom_schema].[my_table].
The custom schema custom_schema is the default schema of the user used to connect to this DB.
The custom schema is also set in the CakePHP datasource configuration setting schema of this DB to custom_schema.
Baking the migration_diff works fine. It finds the table and generates a migration script.
In that migration script there is no mention of the custom schema, which is OK.
Actual Behavior
When I use that migration script though, it creates the table as [my_database].[dbo].[my_table].
Expected Behavior
Creating the table as [my_database].[custom_schema].[my_table].
Reason
In Phinx, schema is set to dbo but never gets overwritten.
I am also facing a similar issue while using phinx with SQL server. Is there any update on this?
The table should be created within the user's default schema instead of dbo.
It can be fixed by query DB to get the default schema name and set it to $schema property, after the connection is established.
$result = $this->fetchRow("SELECT SCHEMA_NAME() as schema_name");
$this->schema= $result['schema_name'];
What you did
I have created a table in a database on a MS SQL Server in a schema other than the default one
dbo
, e.g.[my_database].[custom_schema].[my_table]
.The custom schema
custom_schema
is the default schema of the user used to connect to this DB.The custom schema is also set in the CakePHP datasource configuration setting
schema
of this DB tocustom_schema
.Baking the
migration_diff
works fine. It finds the table and generates a migration script.In that migration script there is no mention of the custom schema, which is OK.
Actual Behavior
When I use that migration script though, it creates the table as
[my_database].[dbo].[my_table]
.Expected Behavior
Creating the table as
[my_database].[custom_schema].[my_table]
.Reason
In Phinx,
schema
is set todbo
but never gets overwritten.https://github.com/cakephp/phinx/blob/0.11.4/src/Phinx/Db/Adapter/SqlServerAdapter.php#L32
Related
Somewhat releated issue (about PostgreSQL):
#254
The text was updated successfully, but these errors were encountered: