其他表正常时,将不会创建用户表

时间:2019-04-27 14:53:12

标签: php doctrine symfony4

我有这个symfony应用程序可以用作参考和学习工具,它不是我写的。无论如何使用该应用程序,我都需要创建数据库和表,但是当尝试使用主义迁移时,它会抱怨存在一些语法错误,因为我没有编写SQL代码,所以我不知道这是怎么回事,因为它停止了仅在用户表上,但是成功创建了其他表。 这是错误消息:

  

执行'CREATE TABLE用户(id INT AUTO_INCREMENT NOT NULL,发送电子邮件VARCHAR(180)NOT NULL,角色JSON NOT NULL,密码VARCHAR(255)NOT NU
时发生异常     LL,名称VARCHAR(50)非空,is_blocked TINYINT(1)非空,唯一索引UNIQ_8D93D649E7927C74(电子邮件),主键(id))默认字符集utf8mb4 COLLUT utf
    8mb4_unicode_ci ENGINE = InnoDB':

     

SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法有一个错误;请参见语法。请查看与您的MariaDB服务器版本相对应的手册
    在第1行的'JSON NOT NULL,passw VARCHAR(255)NOT NULL,name VARCHAR(50)NOT NULL,is_blocke'附近使用正确的语法

这是生成的迁移:

    $this->addSql('CREATE TABLE country (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(30) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
    $this->addSql('CREATE TABLE game (id INT AUTO_INCREMENT NOT NULL, referee_id INT DEFAULT NULL, tournament_id INT NOT NULL, home_team_id INT NOT NULL, away_team_id INT NOT NULL, date DATETIME NOT NULL, round SMALLINT DEFAULT NULL, game_nr SMALLINT NOT NULL, is_playoffs_game TINYINT(1) NOT NULL, playoffs_round SMALLINT DEFAULT NULL, group_nr SMALLINT DEFAULT NULL, home_score SMALLINT DEFAULT NULL, away_score SMALLINT DEFAULT NULL, INDEX IDX_232B318C4A087CA2 (referee_id), INDEX IDX_232B318C33D1A3E7 (tournament_id), INDEX IDX_232B318C9C4C13F6 (home_team_id), INDEX IDX_232B318C45185D02 (away_team_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
    $this->addSql('CREATE TABLE player (id INT AUTO_INCREMENT NOT NULL, team_id INT NOT NULL, name VARCHAR(100) NOT NULL, goal_count INT NOT NULL, b_date DATETIME NOT NULL, number SMALLINT DEFAULT NULL, INDEX IDX_98197A65296CD8AE (team_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
    $this->addSql('CREATE TABLE team (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, country_id INT NOT NULL, tournament_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, venue VARCHAR(255) DEFAULT NULL, contacts VARCHAR(1000) NOT NULL, region VARCHAR(100) NOT NULL, state SMALLINT NOT NULL, INDEX IDX_C4E0A61FA76ED395 (user_id), INDEX IDX_C4E0A61FF92F3E70 (country_id), INDEX IDX_C4E0A61F33D1A3E7 (tournament_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
    $this->addSql('CREATE TABLE tournament (id INT AUTO_INCREMENT NOT NULL, country_id INT NOT NULL, type_id INT NOT NULL, user_id INT NOT NULL, tournament_desc VARCHAR(1000) DEFAULT NULL, rounds SMALLINT DEFAULT NULL, playoffs_places SMALLINT DEFAULT NULL, rounds_per_pair SMALLINT DEFAULT NULL, group_count SMALLINT DEFAULT NULL, players_on_field SMALLINT NOT NULL, rules VARCHAR(1000) DEFAULT NULL, prizes VARCHAR(255) DEFAULT NULL, region VARCHAR(255) NOT NULL, venue VARCHAR(255) DEFAULT NULL, contacts VARCHAR(255) DEFAULT NULL, code VARCHAR(9) NOT NULL, is_started TINYINT(1) NOT NULL, is_ended TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_BD5FB8D977153098 (code), INDEX IDX_BD5FB8D9F92F3E70 (country_id), INDEX IDX_BD5FB8D9C54C8C93 (type_id), INDEX IDX_BD5FB8D9A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
    $this->addSql('CREATE TABLE tournament_type (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
    $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, passw VARCHAR(255) NOT NULL, name VARCHAR(50) NOT NULL, is_blocked TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
    $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C4A087CA2 FOREIGN KEY (referee_id) REFERENCES user (id)');
    $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C33D1A3E7 FOREIGN KEY (tournament_id) REFERENCES tournament (id)');
    $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C9C4C13F6 FOREIGN KEY (home_team_id) REFERENCES team (id)');
    $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C45185D02 FOREIGN KEY (away_team_id) REFERENCES team (id)');
    $this->addSql('ALTER TABLE player ADD CONSTRAINT FK_98197A65296CD8AE FOREIGN KEY (team_id) REFERENCES team (id)');
    $this->addSql('ALTER TABLE team ADD CONSTRAINT FK_C4E0A61FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
    $this->addSql('ALTER TABLE team ADD CONSTRAINT FK_C4E0A61FF92F3E70 FOREIGN KEY (country_id) REFERENCES country (id)');
    $this->addSql('ALTER TABLE team ADD CONSTRAINT FK_C4E0A61F33D1A3E7 FOREIGN KEY (tournament_id) REFERENCES tournament (id)');
    $this->addSql('ALTER TABLE tournament ADD CONSTRAINT FK_BD5FB8D9F92F3E70 FOREIGN KEY (country_id) REFERENCES country (id)');
    $this->addSql('ALTER TABLE tournament ADD CONSTRAINT FK_BD5FB8D9C54C8C93 FOREIGN KEY (type_id) REFERENCES tournament_type (id)');
    $this->addSql('ALTER TABLE tournament ADD CONSTRAINT FK_BD5FB8D9A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');

0 个答案:

没有答案