Skip to content
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

Table columns with default values (i.e. ClassName) are not properly created after dev/build #56

Open
bilekt3 opened this issue Jun 3, 2019 · 1 comment

Comments

@bilekt3
Copy link

bilekt3 commented Jun 3, 2019

On our current project where we trying to upgrade SS3 to SS4 with this library we have realized that some tables are not created correctly (usually missing default values for ClassName etc.), we are able to fix almost everything by manual changes of database structure, but after dev/build task all changes are replaced.

System:
PHP7.2, IIS, SQL SErver Express (2012)

Sample table structure with incorrect table structure:

create table ChangeSetItem
(
    ID            int identity
        constraint PK__ChangeSe__3214EC27AF81A266
            primary key,
    ClassName     varchar(36)                      not null,
    LastEdited    datetime,
    Created       datetime,
    VersionBefore int         default 0            not null,
    VersionAfter  int         default 0            not null,
    Added         varchar(10) default 'implicitly' not null
        constraint ChangeSetItem_Added_check
            check ([Added] = 'implicitly' OR [Added] = 'explicitly'),
    ChangeSetID   int         default 0            not null,
    ObjectID      int         default 0            not null,
    ObjectClass   varchar(40) default 'SearchTag'  not null
)
go
@t3hn0
Copy link

t3hn0 commented Feb 25, 2021

I encountered same problem - ClassName constraint didn't update after it was created initially.

Server: PHP 7.2., IIS, MS SQL 2019
Installation:

  • SS 4.7.2
  • silverstripe/mssql: 2.0.3
  • tractorcow/silverstripe-fluent: 5.0.0
  • dnadesign/silverstripe-elemental: 4.0.0

I found error or should I say incomplete regex in MSSQLSchemaManager which wasn't able to read constraint definition if they contained symbol "" in it. ClassName contains namespaces which contain a lot of backslashes :)

I added PR #61 which adds support to backslashes, and now it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants