Skip to content

Commit 841df77

Browse files
committed
Fix migrations
1 parent 174ba72 commit 841df77

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

app/Migrations/Schema/V110/Version110.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,13 @@ public function up(Schema $schema)
276276
}
277277

278278
if ($schema->hasTable('c_attendance_calendar_rel_group')) {
279-
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NOT NULL");
280-
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group DROP PRIMARY KEY");
281-
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NULL DEFAULT NULL");
282-
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
279+
$table = $schema->getTable('c_attendance_calendar_rel_group');
280+
if ($table->hasColumn('iid') === false) {
281+
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NOT NULL");
282+
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group DROP PRIMARY KEY");
283+
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NULL DEFAULT NULL");
284+
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
285+
}
283286
}
284287

285288
$this->addSql("ALTER TABLE c_attendance_sheet MODIFY COLUMN c_id INT NOT NULL");

app/Migrations/Schema/V110/Version20150522112023.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ public function up(Schema $schema)
2121

2222
$this->addSql('ALTER TABLE usergroup ADD group_type INT NOT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME NOT NULL');
2323
$this->addSql('ALTER TABLE usergroup ADD picture VARCHAR(255) DEFAULT NULL, ADD url VARCHAR(255) DEFAULT NULL, ADD visibility VARCHAR(255) NOT NULL, ADD allow_members_leave_group INT NOT NULL, CHANGE description description LONGTEXT');
24-
$this->addSql('CREATE TABLE usergroup_rel_usergroup (id INT AUTO_INCREMENT NOT NULL, group_id INT NOT NULL, subgroup_id INT NOT NULL, relation_type INT NOT NULL, PRIMARY KEY(id))');
24+
25+
if (!$schema->hasTable('usergroup_rel_usergroup')) {
26+
$this->addSql(
27+
'CREATE TABLE usergroup_rel_usergroup (id INT AUTO_INCREMENT NOT NULL, group_id INT NOT NULL, subgroup_id INT NOT NULL, relation_type INT NOT NULL, PRIMARY KEY(id))'
28+
);
29+
}
30+
2531
$this->addSql('ALTER TABLE usergroup_rel_user ADD relation_type INT');
2632

2733
if (!$schema->hasTable('access_url_rel_usergroup')) {

0 commit comments

Comments
 (0)