<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230908151529 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) NOT NULL,
`email` varchar(100) NOT NULL,
`roles` text NOT NULL,
`password` varchar(100) NOT NULL,
`is_verified` tinyint(2) NOT NULL DEFAULT 0,
`is_active` tinyint(2) NOT NULL DEFAULT 1,
`created_at` datetime(6) DEFAULT NULL,
`updated_at` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci');
$this->addSql('CREATE TABLE IF NOT EXISTS `user_profile` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`profile_image` varchar(50) DEFAULT NULL,
`contact_number` varchar(50) DEFAULT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `user_profile_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci');
$this->addSql("CREATE TABLE IF NOT EXISTS `reset_password_request` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`selector` varchar(20) NOT NULL,
`hashed_token` varchar(100) NOT NULL,
`requested_at` datetime NOT NULL COMMENT '(DC2Type:datetime_immutable)',
`expires_at` datetime NOT NULL COMMENT '(DC2Type:datetime_immutable)',
PRIMARY KEY (`id`) USING BTREE,
KEY `IDX_7CE748AA76ED395` (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci");
// INSERT INTO user
$userData = array(
array(1, 'admin', '[email protected]', '["ROLE_ADMIN"]','$2y$13$lkpQ20pF267MvLZp8Y8VI.5672BdyRT.ghQoM0gWpWiGj/w8pta2G', 1, 1),
);
foreach($userData as $d) {
$this->addSql('INSERT INTO `user` (`id`,`user_name`, `email`, `roles`, `password`, `is_verified`, `is_active`) '
. ' VALUES (?,?,?,?,?,?,?)', $d);
}
// INSERT INTO user
$userProfileData = array(
array(1, 1, 'ADMIN', 'LTS'),
);
foreach($userProfileData as $d) {
$this->addSql('INSERT INTO `user_profile` (`id`, `user_id`, `first_name`, `last_name`) '
. ' VALUES (?,?,?,?)', $d);
}
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS `user_profile`;');
$this->addSql('DROP TABLE IF EXISTS `reset_password_request`;');
$this->addSql('DROP TABLE IF EXISTS `user`;');
}
}