Comments (3)
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.
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.
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)
- Error if Default column value is CURRENT_TIMESTAMP HOT 1
- Stable Release HOT 5
- Some JQuery functionalities not working HOT 4
- Missing 2 Classes on a commit cause fatal error and exception! HOT 1
- Composite primary keys HOT 4
- table prefix ignored HOT 1
- Tool doesn't set default value for integer if it is 0 HOT 1
- SHOW INDEX FROM executed on PostgoreSQL database HOT 5
- demo not working HOT 3
- addcslashes in insert statements HOT 1
- validateCsrfToken() issue HOT 3
- Incorrect enum options escaping and uppercase HOT 1
- Probably incorrect array check. HOT 1
- DB prefix in addForeignKey HOT 1
- good day. HOT 2
- not working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-migration-utility.