migrations/Version20230719053240.php line 1

  1. <?php
    
    declare(strict_types=1);
    
    namespace DoctrineMigrations;
    
    use Doctrine\DBAL\Schema\Schema;
    use Doctrine\Migrations\AbstractMigration;
    
    /**
     * Auto-generated Migration: Please modify to your needs!
     */
    final class Version20230719053240 extends AbstractMigration
    {
        public function getDescription(): string
        {
            return '';
        }
    
        public function up(Schema $schema): void
        {
            // this up() migration is auto-generated, please modify it to your needs
            $this->addSql('ALTER TABLE item ADD COLUMN held_by SMALLINT DEFAULT NULL');
            $this->addSql('ALTER TABLE item ADD COLUMN held_by_table CLOB DEFAULT NULL');
            $this->addSql('ALTER TABLE playable_entity ADD COLUMN held_with_table CLOB DEFAULT NULL');
            $this->addSql('ALTER TABLE user ADD COLUMN avatar VARCHAR(255) DEFAULT NULL');
        }
    
        public function down(Schema $schema): void
        {
            // this down() migration is auto-generated, please modify it to your needs
            $this->addSql('CREATE TEMPORARY TABLE __temp__item AS SELECT id, playable_entity_equipped_id, unplayable_entity_equipped_id, artifact_entity_equipped_id, inside_of_id, held_id, place_equipped_id, name, type, weight, weight_max, size, equippable, container, value, subtype, category, description FROM item');
            $this->addSql('DROP TABLE item');
            $this->addSql('CREATE TABLE item (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, playable_entity_equipped_id INTEGER DEFAULT NULL, unplayable_entity_equipped_id INTEGER DEFAULT NULL, artifact_entity_equipped_id INTEGER DEFAULT NULL, inside_of_id INTEGER DEFAULT NULL, held_id INTEGER DEFAULT NULL, place_equipped_id INTEGER DEFAULT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, weight INTEGER NOT NULL, weight_max INTEGER NOT NULL, size INTEGER NOT NULL, equippable BOOLEAN NOT NULL, container BOOLEAN NOT NULL, value INTEGER DEFAULT NULL, subtype VARCHAR(255) DEFAULT NULL, category VARCHAR(255) DEFAULT NULL, description CLOB DEFAULT NULL, CONSTRAINT FK_1F1B251ED171181E FOREIGN KEY (playable_entity_equipped_id) REFERENCES playable_entity (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_1F1B251E817C99A1 FOREIGN KEY (unplayable_entity_equipped_id) REFERENCES unplayable_entity (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_1F1B251EDE13AB7A FOREIGN KEY (artifact_entity_equipped_id) REFERENCES artifact_entity (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_1F1B251ECDEA07EC FOREIGN KEY (inside_of_id) REFERENCES item (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_1F1B251EC8AA52F FOREIGN KEY (held_id) REFERENCES playable_entity (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_1F1B251EB336493F FOREIGN KEY (place_equipped_id) REFERENCES place (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
            $this->addSql('INSERT INTO item (id, playable_entity_equipped_id, unplayable_entity_equipped_id, artifact_entity_equipped_id, inside_of_id, held_id, place_equipped_id, name, type, weight, weight_max, size, equippable, container, value, subtype, category, description) SELECT id, playable_entity_equipped_id, unplayable_entity_equipped_id, artifact_entity_equipped_id, inside_of_id, held_id, place_equipped_id, name, type, weight, weight_max, size, equippable, container, value, subtype, category, description FROM __temp__item');
            $this->addSql('DROP TABLE __temp__item');
            $this->addSql('CREATE INDEX IDX_1F1B251ED171181E ON item (playable_entity_equipped_id)');
            $this->addSql('CREATE INDEX IDX_1F1B251E817C99A1 ON item (unplayable_entity_equipped_id)');
            $this->addSql('CREATE INDEX IDX_1F1B251EDE13AB7A ON item (artifact_entity_equipped_id)');
            $this->addSql('CREATE INDEX IDX_1F1B251ECDEA07EC ON item (inside_of_id)');
            $this->addSql('CREATE INDEX IDX_1F1B251EC8AA52F ON item (held_id)');
            $this->addSql('CREATE INDEX IDX_1F1B251EB336493F ON item (place_equipped_id)');
            $this->addSql('CREATE TEMPORARY TABLE __temp__playable_entity AS SELECT id, player_id, place_id, name, gender, trombinoscope, size, hp, ap, max_hp, max_ap, armor_class, agility, charisma, intelligence, perception, strength, skills, abilities, known_magicskills, known_attackskills, known_craftskills, race, weight, weight_max, totidy FROM playable_entity');
            $this->addSql('DROP TABLE playable_entity');
            $this->addSql('CREATE TABLE playable_entity (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, player_id INTEGER DEFAULT NULL, place_id INTEGER DEFAULT NULL, name VARCHAR(255) NOT NULL, gender SMALLINT NOT NULL, trombinoscope CLOB DEFAULT NULL --(DC2Type:array)
            , size SMALLINT NOT NULL, hp INTEGER NOT NULL, ap INTEGER NOT NULL, max_hp INTEGER NOT NULL, max_ap INTEGER NOT NULL, armor_class INTEGER NOT NULL, agility INTEGER NOT NULL, charisma INTEGER NOT NULL, intelligence INTEGER NOT NULL, perception INTEGER NOT NULL, strength INTEGER NOT NULL, skills CLOB DEFAULT NULL --(DC2Type:array)
            , abilities CLOB DEFAULT NULL --(DC2Type:array)
            , known_magicskills CLOB DEFAULT NULL --(DC2Type:array)
            , known_attackskills CLOB DEFAULT NULL --(DC2Type:array)
            , known_craftskills CLOB DEFAULT NULL --(DC2Type:array)
            , race VARCHAR(255) NOT NULL, weight INTEGER NOT NULL, weight_max INTEGER NOT NULL, totidy CLOB DEFAULT NULL --(DC2Type:array)
            , CONSTRAINT FK_114242BE99E6F5DF FOREIGN KEY (player_id) REFERENCES user (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_114242BEDA6A219 FOREIGN KEY (place_id) REFERENCES place (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
            $this->addSql('INSERT INTO playable_entity (id, player_id, place_id, name, gender, trombinoscope, size, hp, ap, max_hp, max_ap, armor_class, agility, charisma, intelligence, perception, strength, skills, abilities, known_magicskills, known_attackskills, known_craftskills, race, weight, weight_max, totidy) SELECT id, player_id, place_id, name, gender, trombinoscope, size, hp, ap, max_hp, max_ap, armor_class, agility, charisma, intelligence, perception, strength, skills, abilities, known_magicskills, known_attackskills, known_craftskills, race, weight, weight_max, totidy FROM __temp__playable_entity');
            $this->addSql('DROP TABLE __temp__playable_entity');
            $this->addSql('CREATE INDEX IDX_114242BE99E6F5DF ON playable_entity (player_id)');
            $this->addSql('CREATE INDEX IDX_114242BEDA6A219 ON playable_entity (place_id)');
            $this->addSql('CREATE TEMPORARY TABLE __temp__user AS SELECT id, character_id, nickname, email, roles, password FROM user');
            $this->addSql('DROP TABLE user');
            $this->addSql('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, character_id INTEGER DEFAULT NULL, nickname VARCHAR(255) NOT NULL, email VARCHAR(180) NOT NULL, roles CLOB NOT NULL --(DC2Type:json)
            , password VARCHAR(255) NOT NULL, CONSTRAINT FK_8D93D6491136BE75 FOREIGN KEY (character_id) REFERENCES playable_entity (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
            $this->addSql('INSERT INTO user (id, character_id, nickname, email, roles, password) SELECT id, character_id, nickname, email, roles, password FROM __temp__user');
            $this->addSql('DROP TABLE __temp__user');
            $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON user (email)');
            $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D6491136BE75 ON user (character_id)');
        }
    }