Closed aliechti closed 8 years ago
What is table name? Please show full name.
Try upgrading to code from master.
@samdark With the master version, it does not make any relation independently of the Generate Relations
checkbox.
In order to reproduce it I need database schema and what you're entering in Gii form.
What we've fixed in master version is behavior about broken keys (i.e. when schema has a foreign key pointing to non-existing table). Previously it was erroring, not it skips such relation.
Ok, I've dropped the schema of the Artikel
Table and the related ones for testing. Just pressed preview again and :tada: it works. So this means that the relations do only not work if the tables are in a specific schema. The question is now, why? Does Gii handle schemes not properly?
I have no idea which schemas you're talking about. Without providing a dump to reproduce the issue it could not be solved and even could not be productively discussed.
I'm talking about DB schemas: https://technet.microsoft.com/en-us/library/dd283095(v=sql.100).aspx
Default on MSSQL is dbo
.
Sorry but I cannot give you my dump, its just not opensource. But it is easy testable, just create two Tables in a specific schema and make a relation between them.
Should it be a single schema?
In my case it is a single schema like test
. And some Tables test.table1
, test.table2
and a relation between them.
I ran into this issue as well with Yii2.06/Gii2.04. IF the Generate Relations
is checked (which it seems to be by default) it tosses the same error as above. It's a simple table called logger
. What can I give you that will help? Attached is the mySQL logger table definition dump -
CREATE TABLE `xyz-JATO`.logger (
id int(11) NOT NULL AUTO_INCREMENT,
data_name varchar(255) NOT NULL,
ed_status int(11) DEFAULT NULL,
ed_msg varchar(255) DEFAULT NULL,
ed_url varchar(255) NOT NULL,
dte_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
)
ENGINE = INNODB
AUTO_INCREMENT = 13
AVG_ROW_LENGTH = 1365
CHARACTER SET utf8
COLLATE utf8_unicode_ci;
About the only thing that looks odd is that the table name has a '-' in it and possibly that is causing an issue, reaching here :)
Thanks Sandy
More info -
Seems that the database name is the issue in my case. I changed the name of the DB from xyz-JATO
to 'xyz' and no issues with generation.
I'm facing the same problem on the following configuration:
PHP 5.6/7.0 MySQL 5.6 Yii 2 7ccbfdf4cfb0ce025e27455dc3e516af23eb2800 Gii bb0eba84639a99bff6c8bc9e803bd8ac3ab66297
CREATE TABLE IF NOT EXISTS `phonics_v3_2_1`.`Language` (
`languageCode` VARCHAR(2) NOT NULL COMMENT 'ISO 639-1 Code',
`languageName` VARCHAR(64) NOT NULL,
PRIMARY KEY (`languageCode`))
ENGINE = InnoDB
CREATE TABLE IF NOT EXISTS `phonics_v3_2_1`.`SpellingSystem` (
`spellingCode` VARCHAR(2) NOT NULL,
`languageCode` VARCHAR(2) NOT NULL,
`spellingName` VARCHAR(64) NOT NULL,
PRIMARY KEY (`spellingCode`),
INDEX `SpellingSystemLanguageFK_idx` (`languageCode` ASC),
CONSTRAINT `SpellingSystemLanguageFK`
FOREIGN KEY (`languageCode`)
REFERENCES `phonics_v3_2_1`.`Language` (`languageCode`)
ON DELETE RESTRICT
ON UPDATE RESTRICT)
ENGINE = InnoDB
I can not create SpellingSystem model with references.
Looks like #168
thanks for checking.
I could not find any possible solution, because I just don't know how Gii really works. The error only occurs if
Generate Relations
is checked and looks like this:The settings are:
The DB is a
SQL Server 2014
.