Moved profile about sections into their own table.

This commit is contained in:
flash 2025-02-08 23:20:53 +00:00
parent 8bb2400d3f
commit 372797c564
11 changed files with 218 additions and 108 deletions

View file

@ -0,0 +1,36 @@
<?php
use Index\Db\DbConnection;
use Index\Db\Migration\DbMigration;
final class MovedProfileAboutToDedicatedTable_20250208_225249 implements DbMigration {
public function migrate(DbConnection $conn): void {
$conn->execute(<<<SQL
CREATE TABLE msz_profile_about (
user_id INT UNSIGNED NOT NULL,
about_body TEXT NOT NULL COLLATE 'utf8mb4_unicode_520_ci',
about_body_format ENUM('','bb','md') NOT NULL COLLATE 'ascii_general_ci',
about_created TIMESTAMP NOT NULL DEFAULT NOW(),
PRIMARY KEY (user_id),
CONSTRAINT profile_about_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_about
SELECT user_id, user_about_content, user_about_content_format, NOW()
FROM msz_users
WHERE user_about_content IS NOT NULL
AND TRIM(user_about_content) <> ''
SQL);
$conn->execute(<<<SQL
ALTER TABLE msz_users
DROP COLUMN user_about_content,
DROP COLUMN user_about_content_format;
SQL);
}
}