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

Initialize DB with migration #11

Merged
merged 2 commits into from
Dec 12, 2016
Merged

Initialize DB with migration #11

merged 2 commits into from
Dec 12, 2016

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented Dec 9, 2016

Fixes #10

@CLAassistant
Copy link

CLAassistant commented Dec 9, 2016

CLA assistant check
All committers have signed the CLA.

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 9, 2016

I'm stuck because am unable to create a unique index.
In MDB2 schema we had this:

<index>
    <name>cg_uri_index</name>
    <unique>true</unique>
    <field>
        <name>uri</name>
        <sorting>ascending</sorting>
    </field>
</index>

Now with Doctrine I define it as:

    $table->addUniqueIndex(['uri'], 'cg_uri_index');

But MySQL is not happy:

± % sudo -uwwwrun ./occ app:enable customgroups
                              
  [Doctrine\DBAL\Exception\DriverException]                                                                                                                                                 
  An exception occurred while executing 'CREATE TABLE oc_custom_group (group_id INT UNSIGNED AUTO_INCREMENT NOT NULL, uri TINYTEXT NOT NULL, display_name TINYTEXT NOT NULL, UNIQUE INDEX   
  cg_uri_index (uri), PRIMARY KEY(group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB':                                                                           
  SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'uri' used in key specification without a key length                                                             
                                                                                                                                                                                            

                                                                                                                                 
  [Doctrine\DBAL\Driver\PDOException]                                                                                            
  SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'uri' used in key specification without a key length  
                                                                                                                                 

                                                                                                                                 
  [PDOException]                                                                                                                 
  SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'uri' used in key specification without a key length  

This says that MySQL requires an explicit key length, basically how many of first characters of the field must be indexed: http://stackoverflow.com/a/1827118

However Doctrine doesn't allow you to pass a length for indices: doctrine/orm#3553 (won't fix as too DB specific)

I was told on IRC to try with varchar, let's find out how to do that...

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 9, 2016

Note that in the MDB2 schema the "uri" column was specified as having the type "text" which is somehow mapped to "TINYTEXT"

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 9, 2016

I changed the column type from "text" to "string" and now the index can be created properly.

It is now possible to enable this app and get the initial DB !

@DeepDiver1975 @VicDeo @jvillafanez please review

@PVince81 PVince81 added this to the 10.0 milestone Dec 9, 2016
@PVince81
Copy link
Contributor Author

PVince81 commented Dec 9, 2016

btw, requires owncloud/core#14851 checked out on master for it to work

@PVince81 PVince81 mentioned this pull request Dec 9, 2016
7 tasks
@jvillafanez
Copy link
Member

👍

@PVince81 PVince81 merged commit dad0d07 into master Dec 12, 2016
@PVince81 PVince81 deleted the doctrine-migration-init branch December 12, 2016 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants