You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migrations/Version20231001214112.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -30,8 +30,8 @@ public function down(Schema $schema): void
30
30
{
31
31
$this->skipIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration is specific to \'postgresql\'. Skipping it is fine.');
32
32
33
-
$this->addSql("ALTER TABLE calendarobjects ALTER COLUMN calendardata TYPE BYTEA DEFAULT NULL USING convert_from(calendardata, 'utf8')");
34
-
$this->addSql("ALTER TABLE cards ALTER COLUMN carddata TYPE BYTEA DEFAULT NULL USING convert_from(carddata, 'utf8')");
35
-
$this->addSql("ALTER TABLE schedulingobjects ALTER COLUMN calendardata TYPE BYTEA DEFAULT NULL USING convert_from(calendardata, 'utf8')");
33
+
$this->addSql("ALTER TABLE calendarobjects ALTER COLUMN calendardata TYPE BYTEA USING convert_to(calendardata, 'utf8')");
34
+
$this->addSql("ALTER TABLE cards ALTER COLUMN carddata TYPE BYTEA USING convert_to(carddata, 'utf8')");
35
+
$this->addSql("ALTER TABLE schedulingobjects ALTER COLUMN calendardata TYPE BYTEA USING convert_to(calendardata, 'utf8')");
// Address books created without a display name would violate the restored NOT NULL,
46
+
// so fall back to their uri rather than losing the row.
47
+
$this->addSql('UPDATE addressbooks SET displayname = uri WHERE displayname IS NULL');
48
+
49
+
if ('mysql' === $engine) {
50
+
$this->addSql('ALTER TABLE addressbooks CHANGE displayname displayname VARCHAR(255) NOT NULL');
51
+
} elseif ('postgresql' === $engine) {
52
+
$this->addSql('ALTER TABLE addressbooks ALTER COLUMN displayname SET NOT NULL');
53
+
} elseif ('sqlite' === $engine) {
54
+
// SQLite refuses to ADD a NOT NULL column without a default, so rebuild the table.
55
+
$this->addSql('CREATE TABLE addressbooks_old (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, principaluri VARCHAR(255) NOT NULL, displayname VARCHAR(255) NOT NULL, uri VARCHAR(255) NOT NULL, description CLOB DEFAULT NULL, synctoken VARCHAR(255) NOT NULL, included_in_birthday_calendar INTEGER DEFAULT 0)');
56
+
$this->addSql('INSERT INTO addressbooks_old (id, principaluri, displayname, uri, description, synctoken, included_in_birthday_calendar) SELECT id, principaluri, displayname, uri, description, synctoken, included_in_birthday_calendar FROM addressbooks');
57
+
$this->addSql('DROP TABLE addressbooks');
58
+
$this->addSql('ALTER TABLE addressbooks_old RENAME TO addressbooks');
0 commit comments