Moved profile background settings out of the users table.
This commit is contained in:
parent
9f5076cc77
commit
31d89a08bf
18 changed files with 285 additions and 234 deletions
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
use Index\Db\DbConnection;
|
||||
use Index\Db\Migration\DbMigration;
|
||||
|
||||
final class CreateProfileBackgroundSettingsTable_20250208_175705 implements DbMigration {
|
||||
public function migrate(DbConnection $conn): void {
|
||||
$conn->execute(<<<SQL
|
||||
CREATE TABLE msz_profile_backgrounds (
|
||||
user_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
bg_attach ENUM('cover','stretch','tile','contain') NOT NULL,
|
||||
bg_blend TINYINT UNSIGNED NOT NULL,
|
||||
bg_slide TINYINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (user_id),
|
||||
CONSTRAINT profile_backgrounds_users_foreign
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES msz_users (user_id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
) COLLATE='utf8mb4_bin';
|
||||
SQL);
|
||||
|
||||
$conn->execute(<<<SQL
|
||||
INSERT INTO msz_profile_backgrounds
|
||||
SELECT user_id,
|
||||
CASE (user_background_settings & 0x0F)
|
||||
WHEN 1 THEN 'cover'
|
||||
WHEN 2 THEN 'stretch'
|
||||
WHEN 3 THEN 'tile'
|
||||
WHEN 4 THEN 'contain'
|
||||
END,
|
||||
IF(user_background_settings & 0x10, 1, 0),
|
||||
IF(user_background_settings & 0x20, 1, 0)
|
||||
FROM msz_users
|
||||
WHERE (user_background_settings & 0x0F) BETWEEN 1 AND 4;
|
||||
SQL);
|
||||
|
||||
$conn->execute(<<<SQL
|
||||
ALTER TABLE msz_users
|
||||
DROP COLUMN user_background_settings;
|
||||
SQL);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue