collection-crud/src/Migrations/Version0.php

140 lines
15 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Migrations;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version0 extends AbstractMigration {
public function getDescription(): string
{
return 'Initial Database Setup';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf(
! $this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\PostgreSQLPlatform'."
);
$this->addSql('CREATE TABLE collection.brand_category (category_name VARCHAR(255) NOT NULL, PRIMARY KEY(category_name))');
$this->addSql('CREATE TABLE collection.brand (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX brand_unq ON collection.brand (name)');
$this->addSql('CREATE TABLE collection.cpu_socket_link (cpu_id INT NOT NULL, socket_id INT NOT NULL, PRIMARY KEY(cpu_id, socket_id))');
$this->addSql('CREATE INDEX idx_b1adf47dd20e239c ON collection.cpu_socket_link (socket_id)');
$this->addSql('CREATE INDEX idx_b1adf47d3917014 ON collection.cpu_socket_link (cpu_id)');
$this->addSql('CREATE TABLE collection.battery_type (id SERIAL NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE collection.film_format (id INT NOT NULL, number_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE collection.flash (id SERIAL NOT NULL, brand VARCHAR(255) NOT NULL, model VARCHAR(255) NOT NULL, is_auto_flash BOOLEAN NOT NULL, is_ttl BOOLEAN NOT NULL, ttl_type VARCHAR(255) NOT NULL, is_p_ttl BOOLEAN NOT NULL, p_ttl_type VARCHAR(255) NOT NULL, guide_number VARCHAR(255) DEFAULT NULL, purchase_price MONEY DEFAULT NULL, batteries VARCHAR(255) NOT NULL, notes TEXT DEFAULT NULL, serial VARCHAR(255) DEFAULT NULL, formerly_owned BOOLEAN DEFAULT false NOT NULL, received BOOLEAN DEFAULT false NOT NULL, PRIMARY KEY(id))');
$this->addSql("COMMENT ON COLUMN collection.flash.purchase_price IS '(DC2Type:money)'");
$this->addSql('CREATE TABLE collection.brand_category_link (brand_category VARCHAR(255) NOT NULL, brand_id INT NOT NULL, PRIMARY KEY(brand_id, brand_category))');
$this->addSql('CREATE INDEX IDX_5EBFB63CC17C8AD0 ON collection.brand_category_link (brand_category)');
$this->addSql('CREATE INDEX IDX_5EBFB63C44F5D008 ON collection.brand_category_link (brand_id)');
$this->addSql('CREATE TABLE collection.previously_owned_flash (id SERIAL NOT NULL, brand VARCHAR(255) NOT NULL, model VARCHAR(255) NOT NULL, is_auto_flash BOOLEAN NOT NULL, is_ttl BOOLEAN NOT NULL, ttl_type VARCHAR(255) NOT NULL, is_p_ttl BOOLEAN NOT NULL, p_ttl_type VARCHAR(255) NOT NULL, guide_number VARCHAR(255) DEFAULT NULL, purchase_price MONEY DEFAULT NULL, batteries VARCHAR(255) NOT NULL, notes TEXT DEFAULT NULL, serial VARCHAR(255) DEFAULT NULL, formerly_owned BOOLEAN DEFAULT true NOT NULL, received BOOLEAN DEFAULT true NOT NULL, PRIMARY KEY(id))');
$this->addSql("COMMENT ON COLUMN collection.previously_owned_flash.purchase_price IS '(DC2Type:money)'");
$this->addSql("CREATE TABLE collection.previously_owned_lenses (id SERIAL NOT NULL, brand VARCHAR(64) DEFAULT NULL, coatings VARCHAR(64) DEFAULT NULL, product_line VARCHAR(64) DEFAULT NULL, model VARCHAR(64) DEFAULT NULL, min_f_stop VARCHAR(10) DEFAULT NULL, max_f_stop DOUBLE PRECISION DEFAULT NULL, min_focal_length INT DEFAULT NULL, max_focal_length INT DEFAULT NULL, serial VARCHAR(10) DEFAULT NULL, purchase_price MONEY DEFAULT NULL, notes TEXT DEFAULT NULL, mount VARCHAR(40) DEFAULT NULL, received BOOLEAN NOT NULL, formerly_owned BOOLEAN NOT NULL, front_filter_size NUMERIC(10, 0) DEFAULT NULL, rear_filter_size NUMERIC(10, 0) DEFAULT NULL, is_teleconverter BOOLEAN NOT NULL, design_elements SMALLINT DEFAULT NULL, design_groups SMALLINT DEFAULT NULL, aperture_blades SMALLINT DEFAULT NULL, image_size VARCHAR(255) DEFAULT '35mm' NOT NULL, PRIMARY KEY(id))");
$this->addSql("COMMENT ON COLUMN collection.previously_owned_lenses.purchase_price IS '(DC2Type:money)'");
$this->addSql("CREATE TABLE collection.lenses (id SERIAL NOT NULL, brand VARCHAR(64) DEFAULT NULL, coatings VARCHAR(64) DEFAULT NULL, product_line VARCHAR(64) DEFAULT NULL, model VARCHAR(64) DEFAULT NULL, min_f_stop VARCHAR(10) DEFAULT NULL, max_f_stop DOUBLE PRECISION DEFAULT NULL, min_focal_length INT DEFAULT NULL, max_focal_length INT DEFAULT NULL, serial VARCHAR(10) DEFAULT NULL, purchase_price MONEY DEFAULT NULL, notes TEXT DEFAULT NULL, mount VARCHAR(40) DEFAULT NULL, received BOOLEAN NOT NULL, formerly_owned BOOLEAN NOT NULL, front_filter_size NUMERIC(10, 0) DEFAULT NULL, rear_filter_size NUMERIC(10, 0) DEFAULT NULL, is_teleconverter BOOLEAN NOT NULL, design_elements SMALLINT DEFAULT NULL, design_groups SMALLINT DEFAULT NULL, aperture_blades SMALLINT DEFAULT NULL, image_size VARCHAR(255) DEFAULT '35mm' NOT NULL, PRIMARY KEY(id))");
$this->addSql("COMMENT ON COLUMN collection.lenses.purchase_price IS '(DC2Type:money)'");
$this->addSql("CREATE TABLE collection.film (id SERIAL NOT NULL, brand VARCHAR(255) NOT NULL, product_line VARCHAR(255) DEFAULT NULL, film_name VARCHAR(255) NOT NULL, film_speed_asa INT NOT NULL, film_speed_din INT NOT NULL, film_format VARCHAR(255) NOT NULL, film_base VARCHAR(255) DEFAULT 'Cellulose Triacetate' NOT NULL, unused_rolls INT DEFAULT 0 NOT NULL, developed_rolls INT DEFAULT 0 NOT NULL, chemistry VARCHAR(255) DEFAULT 'C-41' NOT NULL, notes TEXT DEFAULT NULL, film_alias VARCHAR(255) DEFAULT NULL, rolls_in_camera INT DEFAULT 0 NOT NULL, PRIMARY KEY(id))");
$this->addSql('CREATE TABLE collection.fpu (id SERIAL NOT NULL, brand_id INT NOT NULL, socket_id INT NOT NULL, model VARCHAR(255) NOT NULL, clock_speed INT NOT NULL, count INT DEFAULT 1 NOT NULL, notes TEXT DEFAULT NULL, series VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX idx_c741fa58d20e239c ON collection.fpu (socket_id)');
$this->addSql('CREATE INDEX idx_c741fa5844f5d008 ON collection.fpu (brand_id)');
$this->addSql('CREATE TABLE collection.socket (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, other_name VARCHAR(255) DEFAULT NULL, pin_count INT NOT NULL, socket_type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE collection.camera_type (id SERIAL NOT NULL, type VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE collection.cpu (id SERIAL NOT NULL, brand_id INT NOT NULL, architecture VARCHAR(255) NOT NULL, product_line VARCHAR(255) NOT NULL, model VARCHAR(255) NOT NULL, part_number VARCHAR(255) NOT NULL, lot_number VARCHAR(255) DEFAULT NULL, micro_architecture VARCHAR(255) DEFAULT NULL, codename VARCHAR(255) DEFAULT NULL, base_speed INT NOT NULL, boost_speed INT DEFAULT NULL, cores INT NOT NULL, threads INT NOT NULL, igp VARCHAR(255) DEFAULT NULL, voltage DOUBLE PRECISION DEFAULT NULL, tdp INT DEFAULT NULL, process_node INT DEFAULT NULL, count INT NOT NULL, usable BOOLEAN NOT NULL, received BOOLEAN NOT NULL, link VARCHAR(255) NOT NULL, notes TEXT DEFAULT NULL, l1_data_size INT DEFAULT NULL, l1_code_size INT DEFAULT NULL, l1_unified_size INT DEFAULT NULL, l1_unified_way INT DEFAULT NULL, l2_count INT NOT NULL, l2_size INT DEFAULT NULL, l2_way INT DEFAULT NULL, l3_count INT NOT NULL, l3_size INT DEFAULT NULL, l3_way INT DEFAULT NULL, l1_data_way INT DEFAULT NULL, l1_code_way INT DEFAULT NULL, l1_data_count INT DEFAULT NULL, l1_code_count INT DEFAULT NULL, l1_unified_count INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_C18A38B344F5D008 ON collection.cpu (brand_id)');
$this->addSql("COMMENT ON COLUMN collection.cpu.lot_number IS 'The CPU lot number, such as s-spec for Intel CPUs'");
$this->addSql("COMMENT ON COLUMN collection.cpu.base_speed IS 'The stock speed of the cpu in MHz'");
$this->addSql("COMMENT ON COLUMN collection.cpu.boost_speed IS 'The max boost speed of the cpu in MHz, if applicable'");
$this->addSql("COMMENT ON COLUMN collection.cpu.igp IS 'The name of the integrated graphics processor'");
$this->addSql("COMMENT ON COLUMN collection.cpu.usable IS 'Whether the chip is working, and can be used with other hardware I have'");
$this->addSql("COMMENT ON COLUMN collection.cpu.received IS 'Whether I have the chip in my possession (instead of in shipping)'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l1_data_size IS 'The size of each Level 1 data cache in KB'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l1_code_size IS 'The size of each Level 1 instruction cache in KB'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l1_unified_size IS 'The size of each Level 1 unified cache in KB'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l2_count IS 'The number of L2 caches on the package, usually the same as the number of cores'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l2_size IS 'The size of each Level 2 cache in KB'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l3_count IS 'The number of L3 caches on the package'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l3_size IS 'The size of each Level 3 cache in KB'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l1_data_count IS 'The number of L1 data caches on the package, usually the same as the number of cores'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l1_code_count IS 'The number of L1 instruction caches on the package, usually the same as the number of cores'");
$this->addSql("COMMENT ON COLUMN collection.cpu.l1_unified_count IS 'The number of L1 caches on the package, usually the same as the number of cores'");
$this->addSql('CREATE TABLE collection.camera (id SERIAL NOT NULL, type_id INT NOT NULL, brand VARCHAR(64) NOT NULL, mount VARCHAR(32) NOT NULL, model VARCHAR(255) NOT NULL, is_digital BOOLEAN NOT NULL, crop_factor NUMERIC(10, 0) NOT NULL, is_working BOOLEAN NOT NULL, notes TEXT DEFAULT NULL, serial VARCHAR(20) NOT NULL, formerly_owned BOOLEAN NOT NULL, purchase_price MONEY DEFAULT NULL, battery_type VARCHAR(255) DEFAULT NULL, film_format VARCHAR(255) DEFAULT NULL, received BOOLEAN DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_8326CD6CC54C8C93 ON collection.camera (type_id)');
$this->addSql("COMMENT ON COLUMN collection.camera.purchase_price IS '(DC2Type:money)'");
$this->addSql('CREATE TABLE collection.previously_owned_camera (id SERIAL NOT NULL, type_id INT NOT NULL, brand VARCHAR(64) NOT NULL, mount VARCHAR(32) NOT NULL, model VARCHAR(255) NOT NULL, is_digital BOOLEAN NOT NULL, crop_factor NUMERIC(10, 0) NOT NULL, is_working BOOLEAN NOT NULL, notes TEXT DEFAULT NULL, serial VARCHAR(20) NOT NULL, formerly_owned BOOLEAN NOT NULL, purchase_price MONEY DEFAULT NULL, battery_type VARCHAR(255) DEFAULT NULL, film_format VARCHAR(255) DEFAULT NULL, received BOOLEAN DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_78B0E96CC54C8C93 ON collection.previously_owned_camera (type_id)');
$this->addSql("COMMENT ON COLUMN collection.previously_owned_camera.purchase_price IS '(DC2Type:money)'");
$this->addSql('CREATE TABLE collection.gpu_core (id SERIAL NOT NULL, brand_id INT NOT NULL, name VARCHAR(255) NOT NULL, variant VARCHAR(255) DEFAULT NULL, generation_name VARCHAR(255) DEFAULT NULL, architecture VARCHAR(255) DEFAULT NULL, process_node INT DEFAULT NULL, architecture_link VARCHAR(255) DEFAULT NULL, generation_link VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_EE59217D44F5D008 ON collection.gpu_core (brand_id)');
$this->addSql("CREATE TABLE collection.gpu (id SERIAL NOT NULL, board_brand_id INT DEFAULT NULL, gpu_brand_id INT NOT NULL, gpu_core_id INT DEFAULT NULL, reference_model_name VARCHAR(255) NOT NULL, alternate_model_name VARCHAR(255) DEFAULT NULL, notes TEXT DEFAULT NULL, count INT DEFAULT 1 NOT NULL, molex_power INT DEFAULT 0 NOT NULL, pcie_6_pin INT DEFAULT 0 NOT NULL, pcie_8_pin INT DEFAULT 0 NOT NULL, card_key VARCHAR(255) DEFAULT 'PCIe x16' NOT NULL, tdp INT DEFAULT NULL, link VARCHAR(255) DEFAULT NULL, bus_interface VARCHAR(255) DEFAULT NULL, slot_span INT DEFAULT 1 NOT NULL, base_clock INT DEFAULT NULL, boost_clock INT DEFAULT NULL, memory_clock INT DEFAULT NULL, memory_size INT DEFAULT NULL, memory_bus INT DEFAULT NULL, memory_type VARCHAR(255) DEFAULT NULL, shading_units INT DEFAULT NULL, tmus INT DEFAULT NULL, rops INT DEFAULT NULL, compute_units INT DEFAULT NULL, l1_cache VARCHAR(255) DEFAULT NULL, l2_cache VARCHAR(255) DEFAULT NULL, direct_x_support VARCHAR(255) DEFAULT NULL, opengl_support VARCHAR(255) DEFAULT NULL, opencl_support VARCHAR(255) DEFAULT NULL, vulkan_support VARCHAR(255) DEFAULT NULL, shader_model VARCHAR(255) DEFAULT NULL, acquired BOOLEAN DEFAULT true NOT NULL, PRIMARY KEY(id))");
$this->addSql('CREATE INDEX IDX_C683906FD402D3B1 ON collection.gpu (board_brand_id)');
$this->addSql('CREATE INDEX IDX_C683906F4561DE01 ON collection.gpu (gpu_brand_id)');
$this->addSql('CREATE INDEX IDX_C683906F87059374 ON collection.gpu (gpu_core_id)');
$this->addSql("COMMENT ON COLUMN collection.gpu.card_key IS 'The shape of the card connector'");
$this->addSql("COMMENT ON COLUMN collection.gpu.tdp IS 'Thermal Design Power (in Watts)'");
$this->addSql("COMMENT ON COLUMN collection.gpu.bus_interface IS 'The type of electrical bus this card uses'");
$this->addSql("COMMENT ON COLUMN collection.gpu.slot_span IS 'How many expansion slots the card occupies'");
$this->addSql("COMMENT ON COLUMN collection.gpu.base_clock IS 'Base speed of the gpu core, in MHz'");
$this->addSql("COMMENT ON COLUMN collection.gpu.boost_clock IS 'GPU core boost clock, in MHz'");
$this->addSql("COMMENT ON COLUMN collection.gpu.memory_clock IS 'Clock speed of the VRAM, in MHz'");
$this->addSql("COMMENT ON COLUMN collection.gpu.memory_size IS 'VRAM size, in MiB'");
$this->addSql("COMMENT ON COLUMN collection.gpu.memory_bus IS 'The width of the memory bus in bits'");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf(
! $this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\PostgreSQLPlatform'."
);
$this->addSql('DROP TABLE collection.brand_category');
$this->addSql('DROP TABLE collection.brand');
$this->addSql('DROP TABLE collection.cpu_socket_link');
$this->addSql('DROP TABLE collection.battery_type');
$this->addSql('DROP TABLE collection.film_format');
$this->addSql('DROP TABLE collection.flash');
$this->addSql('DROP TABLE collection.brand_category_link');
$this->addSql('DROP TABLE collection.previously_owned_flash');
$this->addSql('DROP TABLE collection.previously_owned_lenses');
$this->addSql('DROP TABLE collection.lenses');
$this->addSql('DROP TABLE collection.film');
$this->addSql('DROP TABLE collection.fpu');
$this->addSql('DROP TABLE collection.socket');
$this->addSql('DROP TABLE collection.camera_type');
$this->addSql('DROP TABLE collection.cpu');
$this->addSql('DROP TABLE collection.camera');
$this->addSql('DROP TABLE collection.previously_owned_camera');
$this->addSql('DROP TABLE collection.gpu_core');
$this->addSql('DROP TABLE collection.gpu');
}
}