c006 / yii2-migration-utility Goto Github PK
View Code? Open in Web Editor NEWAutomatically writes the create tables for migrations or create tables in general. Uses MySQL
License: MIT License
Automatically writes the create tables for migrations or create tables in general. Uses MySQL
License: MIT License
Hi. I had to change line 166 in DefaultController to
.. addcslashes($row[ $column->name ], "'") ..
because of unneeded slashes before double quotes... (btw. using mysql)
Hi,
There is a JQuery error:
backend.local/:368 Uncaught ReferenceError: jQuery is not defined
I think this is happening because the hardcoded js code in the view.
Thanks
is it only me or the demo link is actually not responding http://demo.c006.us/ , i get the following
The connection has timed out
The server at demo.c006.us is taking too long to respond.
The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer’s network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
i do not have any firewall installed.
yii2-migration-utility/assets/AppUtility.php
Line 105 in 5b89422
I have many tables with integer fields, for example:
All default values in these fileds are set to 0 in DB.
However after migration generation I get such result:
'sum' => 'INT(14) NOT NULL',
'datetime' => 'INT(14) NOT NULL',
'deleted' => 'TYNTINT(1) NOT NULL',
It's wrong. Many of insertings to DB don't work after applying such migration.
To fix it it must be like:
'sum' => 'INT(14) NOT NULL DEFAULT 0',
'datetime' => 'INT(14) NOT NULL DEFAULT 0',
'deleted' => 'TYNTINT(1) NOT NULL DEFAULT 0',
However if default field value differs from 0, all is generating correctly:
'key' => 'INT(11) NOT NULL DEFAULT \'1\'',
Please fix it.
Hi,
Thank you for this extension!
Are you planning to release a stable version soon?
Then I use table with prefix (tbl),
I get genereted ForeignKey with mistake
$this->addForeignKey(
'fk_tbl_article_tbl_article_lang',
'{{%tbl_article_lang}}', 'article_id',
'{{%tbl_article}}', 'id',
'CASCADE', 'DELETE'
);
// need {{%article}} and {{%article_lang}}
I have realized that there is an issue with composite keys.
Hi,
Was very happy that I found your utility, but it does not work on YII2...
suggest
in actionIndex
.....
foreach ($tables as $table) {
$columns = \Yii::$app->db->getTableSchema($table);
$prefix=\Yii::$app->db->tablePrefix;
$table_prepared=str_replace($prefix,'', $table);
foreach ($databaseType as $dbType) {
if ( $ifThen )
$string .= $this->Nw . 'if ($dbType == "' . $dbType . '") {';
$string .= $this->Nw . '/* ' . strtoupper($dbType) . ' */';
$string .= $this->Nw . '$this->createTable(\'{{%' . $table_prepared . '}}\', [' . $this->Nw;
...
i try to use it on advanced app from yii2, but when i go http://backend.local/utility/index for example, nothing appears, and already make all configuration rigth., i miss something?..
thanks.
I try generate table with enum field, and recieve
$this->createTable('{{%statepusher}}', [
'id' => 'INT(11) NOT NULL AUTO_INCREMENT',
'pusher_id' => 'VARCHAR(100) NOT NULL',
'message' => 'TEXT NOT NULL',
'type' => 'ENUM('MESS','COUNTER') NOT NULL DEFAULT \'mess\'',
'created' => 'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ',
0 => 'PRIMARY KEY (`id`)'
], $tableOptions);
But expected
'type' => 'ENUM(\'mess\',\'counter\') NOT NULL DEFAULT \'mess\'',
(tested with mysql table only)
For fix in AppUtility.php
private function runMySql()
{
if ( isset($this->array['dbType']) )
$this->string .= $this->Tab . "'{$this->array['name']}' => '" . strtoupper($this->array['dbType']) . "";
if ( isset($this->array['allowNull']) )
$this->string .= ($this->array['allowNull']) ? ' NULL' : ' NOT NULL';
if ( isset($this->array['autoIncrement']) )
$this->string .= ($this->array['autoIncrement']) ? ' AUTO_INCREMENT' : '';
if ( isset($this->array['defaultValue']) )
if(!is_array($this->array['defaultValue'])){
$this->string .= (empty($this->array['defaultValue'])) ? '' : " DEFAULT \'{$this->array['defaultValue']}\'";
}else{
$this->string .= (empty($this->array['defaultValue'])) ? '' : " DEFAULT ".$this->array['defaultValue']['expression']." ";
}
}
Refer to this pull request, there are 2 missing classes in default controller from this commit!
I don't know if it is the fault of the new version but I have not used the utility for more than 24 days, today strangely after a clone and composer update, as soon as I point to the url / miaApp / utility I have this return error:
Call to a member function validateCsrfToken() on string
in /var/www/html/motorizzazione/vendor/yiisoft/yii2/web/Controller.php
(and SQLSTATE[42601]: Syntax error
)
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.