-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
952c80c
commit 3cfe5ba
Showing
10 changed files
with
83 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/migrations/Migration202404190001RenameFlusioServiceToFlus.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Website\migrations; | ||
|
||
class Migration202404190001RenameFlusioServiceToFlus | ||
{ | ||
public function migrate(): bool | ||
{ | ||
$database = \Minz\Database::get(); | ||
|
||
$database->beginTransaction(); | ||
|
||
$database->exec(<<<'SQL' | ||
UPDATE accounts | ||
SET preferred_service = 'flus' | ||
WHERE preferred_service = 'flusio'; | ||
ALTER TABLE accounts | ||
RENAME COLUMN preferred_service | ||
TO old_preferred_service; | ||
ALTER TABLE accounts | ||
ADD COLUMN preferred_service TEXT NOT NULL DEFAULT 'flus'; | ||
UPDATE accounts | ||
SET preferred_service = old_preferred_service; | ||
ALTER TABLE accounts | ||
DROP COLUMN old_preferred_service; | ||
SQL); | ||
|
||
$database->commit(); | ||
|
||
return true; | ||
} | ||
|
||
public function rollback(): bool | ||
{ | ||
$database = \Minz\Database::get(); | ||
|
||
$database->beginTransaction(); | ||
|
||
$database->exec(<<<'SQL' | ||
UPDATE accounts | ||
SET preferred_service = 'flusio' | ||
WHERE preferred_service = 'flus'; | ||
ALTER TABLE accounts | ||
RENAME COLUMN preferred_service | ||
TO old_preferred_service; | ||
ALTER TABLE accounts | ||
ADD COLUMN preferred_service TEXT NOT NULL DEFAULT 'flusio'; | ||
UPDATE accounts | ||
SET preferred_service = old_preferred_service; | ||
ALTER TABLE accounts | ||
DROP COLUMN old_preferred_service; | ||
SQL); | ||
|
||
$database->commit(); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters