Moved passwords out of the users table.
This commit is contained in:
parent
7f85abba6e
commit
f39e1230c5
13 changed files with 202 additions and 97 deletions
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
use Index\Db\DbConnection;
|
||||
use Index\Db\Migration\DbMigration;
|
||||
|
||||
final class MovedPasswordsOutOfTheUserTable_20250208_235046 implements DbMigration {
|
||||
public function migrate(DbConnection $conn): void {
|
||||
$conn->execute(<<<SQL
|
||||
CREATE TABLE msz_users_passwords (
|
||||
user_id INT(10) UNSIGNED NOT NULL,
|
||||
password_hash VARCHAR(255) NOT NULL COLLATE 'ascii_bin',
|
||||
password_created TIMESTAMP NOT NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (user_id),
|
||||
CONSTRAINT users_passwords_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 msz_users_passwords
|
||||
SELECT user_id, user_password, NOW()
|
||||
FROM msz_users
|
||||
WHERE user_password IS NOT NULL AND TRIM(user_password) <> ''
|
||||
SQL);
|
||||
|
||||
$conn->execute(<<<SQL
|
||||
ALTER TABLE msz_users
|
||||
DROP COLUMN user_password;
|
||||
SQL);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue