<?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 Version20210728094150 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('CREATE TABLE assetname (id INT AUTO_INCREMENT NOT NULL, groups_id INT NOT NULL, subgroup_id INT NOT NULL, unit_id INT NOT NULL, name VARCHAR(255) NOT NULL, remarks VARCHAR(255) DEFAULT NULL, note VARCHAR(255) DEFAULT NULL, status INT DEFAULT NULL, type INT DEFAULT NULL, entrydate DATETIME DEFAULT NULL, entryby INT DEFAULT NULL, editdate DATETIME DEFAULT NULL, editby DATETIME DEFAULT NULL, INDEX IDX_7942A470F373DCF (groups_id), INDEX IDX_7942A470F5C464CE (subgroup_id), INDEX IDX_7942A470F8BD700D (unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE assetregister (id INT AUTO_INCREMENT NOT NULL, groups_id INT NOT NULL, subgroup_id INT NOT NULL, assetname_id INT NOT NULL, unit_id INT NOT NULL, vendor_id INT NOT NULL, businessunit_id INT NOT NULL, location_id INT DEFAULT NULL, acquisitiondate DATE NOT NULL, acquisitioncost DOUBLE PRECISION NOT NULL, serialno VARCHAR(150) NOT NULL, quantity DOUBLE PRECISION NOT NULL, disposaldate DATE DEFAULT NULL, disposalamount DOUBLE PRECISION DEFAULT NULL, docpath VARCHAR(255) DEFAULT NULL, remarks VARCHAR(255) DEFAULT NULL, openingbalence DOUBLE PRECISION DEFAULT NULL, note VARCHAR(255) DEFAULT NULL, spnote VARCHAR(255) DEFAULT NULL, status INT DEFAULT NULL, type INT DEFAULT NULL, active INT DEFAULT NULL, entrydate DATETIME DEFAULT NULL, entryby INT DEFAULT NULL, editdate DATETIME DEFAULT NULL, editby INT DEFAULT NULL, totaldepdays INT NOT NULL, lastdepdate DATE NOT NULL, depreciationrate DOUBLE PRECISION NOT NULL, INDEX IDX_485FE03FF373DCF (groups_id), INDEX IDX_485FE03FF5C464CE (subgroup_id), INDEX IDX_485FE03F6009F448 (assetname_id), INDEX IDX_485FE03FF8BD700D (unit_id), INDEX IDX_485FE03FF603EE73 (vendor_id), INDEX IDX_485FE03F5A2ED874 (businessunit_id), INDEX IDX_485FE03F64D218E (location_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE businessunit (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, shortname VARCHAR(255) NOT NULL, remarks VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE `group` (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(150) NOT NULL, depreciationrate DOUBLE PRECISION NOT NULL, remarks VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE location (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, remarks VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE subgroup (id INT AUTO_INCREMENT NOT NULL, groups_id INT NOT NULL, name VARCHAR(255) NOT NULL, remarks VARCHAR(255) DEFAULT NULL, INDEX IDX_1773AB1FF373DCF (groups_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE unit (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, shortname VARCHAR(100) NOT NULL, remarks VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE vendor (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, mobileno VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, remarks VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE assetname ADD CONSTRAINT FK_7942A470F373DCF FOREIGN KEY (groups_id) REFERENCES `group` (id)');
        $this->addSql('ALTER TABLE assetname ADD CONSTRAINT FK_7942A470F5C464CE FOREIGN KEY (subgroup_id) REFERENCES subgroup (id)');
        $this->addSql('ALTER TABLE assetname ADD CONSTRAINT FK_7942A470F8BD700D FOREIGN KEY (unit_id) REFERENCES unit (id)');
        $this->addSql('ALTER TABLE assetregister ADD CONSTRAINT FK_485FE03FF373DCF FOREIGN KEY (groups_id) REFERENCES `group` (id)');
        $this->addSql('ALTER TABLE assetregister ADD CONSTRAINT FK_485FE03FF5C464CE FOREIGN KEY (subgroup_id) REFERENCES subgroup (id)');
        $this->addSql('ALTER TABLE assetregister ADD CONSTRAINT FK_485FE03F6009F448 FOREIGN KEY (assetname_id) REFERENCES assetname (id)');
        $this->addSql('ALTER TABLE assetregister ADD CONSTRAINT FK_485FE03FF8BD700D FOREIGN KEY (unit_id) REFERENCES unit (id)');
        $this->addSql('ALTER TABLE assetregister ADD CONSTRAINT FK_485FE03FF603EE73 FOREIGN KEY (vendor_id) REFERENCES vendor (id)');
        $this->addSql('ALTER TABLE assetregister ADD CONSTRAINT FK_485FE03F5A2ED874 FOREIGN KEY (businessunit_id) REFERENCES businessunit (id)');
        $this->addSql('ALTER TABLE assetregister ADD CONSTRAINT FK_485FE03F64D218E FOREIGN KEY (location_id) REFERENCES location (id)');
        $this->addSql('ALTER TABLE subgroup ADD CONSTRAINT FK_1773AB1FF373DCF FOREIGN KEY (groups_id) REFERENCES `group` (id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE assetregister DROP FOREIGN KEY FK_485FE03F6009F448');
        $this->addSql('ALTER TABLE assetregister DROP FOREIGN KEY FK_485FE03F5A2ED874');
        $this->addSql('ALTER TABLE assetname DROP FOREIGN KEY FK_7942A470F373DCF');
        $this->addSql('ALTER TABLE assetregister DROP FOREIGN KEY FK_485FE03FF373DCF');
        $this->addSql('ALTER TABLE subgroup DROP FOREIGN KEY FK_1773AB1FF373DCF');
        $this->addSql('ALTER TABLE assetregister DROP FOREIGN KEY FK_485FE03F64D218E');
        $this->addSql('ALTER TABLE assetname DROP FOREIGN KEY FK_7942A470F5C464CE');
        $this->addSql('ALTER TABLE assetregister DROP FOREIGN KEY FK_485FE03FF5C464CE');
        $this->addSql('ALTER TABLE assetname DROP FOREIGN KEY FK_7942A470F8BD700D');
        $this->addSql('ALTER TABLE assetregister DROP FOREIGN KEY FK_485FE03FF8BD700D');
        $this->addSql('ALTER TABLE assetregister DROP FOREIGN KEY FK_485FE03FF603EE73');
        $this->addSql('DROP TABLE assetname');
        $this->addSql('DROP TABLE assetregister');
        $this->addSql('DROP TABLE businessunit');
        $this->addSql('DROP TABLE `group`');
        $this->addSql('DROP TABLE location');
        $this->addSql('DROP TABLE subgroup');
        $this->addSql('DROP TABLE unit');
        $this->addSql('DROP TABLE vendor');
    }
}
