Giter VIP home page Giter VIP logo

Comments (3)

c006 avatar c006 commented on July 3, 2024

Thanks, glad it works for you.

I appreciate the code.
Hadn't tested for multiple PK's.

I'll put that on the list to do.

Regards,
Jon

On Thu, Sep 24, 2015 at 8:20 PM, Ratacibernetica [email protected]
wrote:

I had a couple tables with 2 primary keys in my Schema (was using
dektrium's yii2-user).

This is the code that generates the error:

/* MYSQL */ if (!in_array('auth_assignment', $tables)) { if ($dbType == "mysql") { $this->createTable('{{%auth_assignment}}', [ 'item_name' => 'VARCHAR(64) NOT NULL', 0 => 'PRIMARY KEY (item_name)', 'user_id' => 'VARCHAR(64) NOT NULL', 1 => 'PRIMARY KEY (user_id)', 'created_at' => 'INT(11) NULL', ], $tableOptions_mysql); } }

Solved it by changing it to:

/* MYSQL */ if (!in_array('auth_assignment', $tables)) { if ($dbType == "mysql") { $this->createTable('{{%auth_assignment}}', [ 'item_name' => 'VARCHAR(64) NOT NULL', 'user_id' => 'VARCHAR(64) NOT NULL', 'created_at' => 'INT(11) NULL', ], $tableOptions_mysql); $this->addPrimaryKey('auth_assignment_pk','auth_assignment',['item_name','user_id']); } }

Other than that, everything worked fine!

Great plugin, thanks!


Reply to this email directly or view it on GitHub
#13.

from yii2-migration-utility.

c006 avatar c006 commented on July 3, 2024

Hi.

Thank you for the code, I will add it.
I had not thought of composite keys.

Regards,
Jon

On Wed, Dec 9, 2015 at 4:51 AM, Sedov Sergey [email protected]
wrote:

or change source in DefaultController.php in line 90

$k = 0; foreach ($columns->columns as $column) { $appUtility = new AppUtility($column, $dbType); $output->addStr($appUtility->string . "',"); if ($column->isPrimaryKey) { $output->addStr($k . " => 'PRIMARY KEY (" . $column->name . ")',"); } $k++; }

to

$k = 0; $pk = false; foreach ($columns->columns as $column) { $appUtility = new AppUtility($column, $dbType); $output->addStr($appUtility->string . "',"); if ($column->isPrimaryKey && !$pk) { $output->addStr($k . " => 'PRIMARY KEY (" . $column->name . ")',"); $pk = true; } elseif ($column->isPrimaryKey && $pk) $output->addStr($k . " => 'KEY (" . $column->name . ")',"); $k++; }


Reply to this email directly or view it on GitHub
#13 (comment)
.

from yii2-migration-utility.

antick avatar antick commented on July 3, 2024

I have encountered the same issue. I think you closed this but haven't fixed the code yet.

from yii2-migration-utility.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.