Update DB to version 13: Add fields to sound_synths and drop music_synths.

This commit is contained in:
2018-04-27 18:12:23 +01:00
parent 53e924055a
commit 40d07af9c5
2 changed files with 164 additions and 35 deletions

View File

@@ -49,111 +49,107 @@ namespace Cicm.Database
IDbCommand dbCmd = dbCon.CreateCommand();
Console.WriteLine("Creating table `admins`");
dbCmd.CommandText = V12.Admins;
dbCmd.CommandText = V13.Admins;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `browser_tests`");
dbCmd.CommandText = V12.BrowserTests;
dbCmd.CommandText = V13.BrowserTests;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `cicm_db`");
dbCmd.CommandText = V12.CicmDb;
dbCmd.CommandText = V13.CicmDb;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `companies`");
dbCmd.CommandText = V12.Companies;
dbCmd.CommandText = V13.Companies;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `computers`");
dbCmd.CommandText = V12.Computers;
dbCmd.CommandText = V13.Computers;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `consoles`");
dbCmd.CommandText = V12.Consoles;
dbCmd.CommandText = V13.Consoles;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `disk_formats`");
dbCmd.CommandText = V12.DiskFormats;
dbCmd.CommandText = V13.DiskFormats;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `forbidden`");
dbCmd.CommandText = V12.Forbidden;
dbCmd.CommandText = V13.Forbidden;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `gpus`");
dbCmd.CommandText = V12.Gpus;
dbCmd.CommandText = V13.Gpus;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `log`");
dbCmd.CommandText = V12.Logs;
dbCmd.CommandText = V13.Logs;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `money_donations`");
dbCmd.CommandText = V12.MoneyDonations;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `music_synths`");
dbCmd.CommandText = V12.MusicSynths;
dbCmd.CommandText = V13.MoneyDonations;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `news`");
dbCmd.CommandText = V12.News;
dbCmd.CommandText = V13.News;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `owned_computers`");
dbCmd.CommandText = V12.OwnedComputers;
dbCmd.CommandText = V13.OwnedComputers;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `owned_consoles`");
dbCmd.CommandText = V12.OwnedConsoles;
dbCmd.CommandText = V13.OwnedConsoles;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `instruction_sets`");
dbCmd.CommandText = V12.InstructionSets;
dbCmd.CommandText = V13.InstructionSets;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `instruction_set_extensions`");
dbCmd.CommandText = V12.InstructionSetExtensions;
dbCmd.CommandText = V13.InstructionSetExtensions;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `processors`");
dbCmd.CommandText = V12.Processors;
dbCmd.CommandText = V13.Processors;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `instruction_set_extensions_by_processor`");
dbCmd.CommandText = V12.InstructionSetExtensionsByProcessor;
dbCmd.CommandText = V13.InstructionSetExtensionsByProcessor;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `sound_synths`");
dbCmd.CommandText = V12.SoundSynths;
dbCmd.CommandText = V13.SoundSynths;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `iso3166_1_numeric`");
dbCmd.CommandText = V12.Iso3166Numeric;
dbCmd.CommandText = V13.Iso3166Numeric;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Filling table `iso3166_1_numeric`");
dbCmd.CommandText = V12.Iso3166NumericValues;
dbCmd.CommandText = V13.Iso3166NumericValues;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating foreign keys for table `companies`");
dbCmd.CommandText = V12.CompaniesForeignKeys;
dbCmd.CommandText = V13.CompaniesForeignKeys;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating foreign keys for table `computers`");
dbCmd.CommandText = V12.ComputersForeignKeys;
dbCmd.CommandText = V13.ComputersForeignKeys;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating foreign keys for table `consoles`");
dbCmd.CommandText = V12.ConsolesForeignKeys;
dbCmd.CommandText = V13.ConsolesForeignKeys;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `company_logos`");
dbCmd.CommandText = V12.CompanyLogos;
dbCmd.CommandText = V13.CompanyLogos;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `company_descriptions`");
dbCmd.CommandText = V12.CompanyDescriptions;
dbCmd.CommandText = V13.CompanyDescriptions;
dbCmd.ExecuteNonQuery();
return true;

View File

@@ -45,9 +45,121 @@ namespace Cicm.Database.Schemas.Sql
public static readonly string Companies = V12.Companies;
public static readonly string Computers = V12.Computers;
public static readonly string Computers =
"CREATE TABLE `computers` (\n" +
"`id` int(11) NOT NULL AUTO_INCREMENT,\n" +
"`company` int(11) NOT NULL DEFAULT '0',\n" +
"`year` int(11) NOT NULL DEFAULT '0',\n" +
"`model` char(50) NOT NULL DEFAULT '',\n" +
"`cpu1` int(11) DEFAULT NULL,\n" +
"`mhz1` int(11) DEFAULT NULL,\n" +
"`cpu2` int(11) DEFAULT NULL,\n" +
"`mhz2` decimal(11,2) DEFAULT NULL,\n" +
"`bits` int(11) NOT NULL DEFAULT '0',\n" +
"`ram` int(11) NOT NULL DEFAULT '0',\n" +
"`rom` int(11) NOT NULL DEFAULT '0',\n" +
"`gpu` int(11) DEFAULT NULL,\n" +
"`vram` int(11) NOT NULL DEFAULT '0',\n" +
"`colors` int(11) NOT NULL DEFAULT '0',\n" +
"`res` char(10) NOT NULL DEFAULT '',\n" +
"`sound_synth` int(11) NOT NULL DEFAULT '0',\n" +
"`music_synth` int(11) NOT NULL DEFAULT '0',\n" +
"`sound_channels` int(11) NOT NULL DEFAULT '0',\n" +
"`music_channels` int(11) NOT NULL DEFAULT '0',\n" +
"`hdd1` int(11) NOT NULL DEFAULT '0',\n" +
"`hdd2` int(11) DEFAULT NULL,\n" +
"`hdd3` int(11) DEFAULT NULL,\n" +
"`disk1` int(11) NOT NULL DEFAULT '0',\n" +
"`cap1` char(25) NOT NULL DEFAULT '0',\n" +
"`disk2` int(11) DEFAULT NULL,\n" +
"`cap2` char(25) DEFAULT NULL,\n" +
"PRIMARY KEY (`id`),\n" +
"KEY `idx_computers_company` (`company`),\n" +
"KEY `idx_computers_year` (`year`),\n" +
"KEY `idx_computers_model` (`model`),\n" +
"KEY `idx_computers_cpu1` (`cpu1`),\n" +
"KEY `idx_computers_cpu2` (`cpu2`),\n" +
"KEY `idx_computers_mhz1` (`mhz1`),\n" +
"KEY `idx_computers_mhz2` (`mhz2`),\n" +
"KEY `idx_computers_bits` (`bits`),\n" +
"KEY `idx_computers_ram` (`ram`),\n" +
"KEY `idx_computers_rom` (`rom`),\n" +
"KEY `idx_computers_gpu` (`gpu`),\n" +
"KEY `idx_computers_vram` (`vram`),\n" +
"KEY `idx_computers_colors` (`colors`),\n" +
"KEY `idx_computers_res` (`res`),\n" +
"KEY `idx_computers_sound_synth` (`sound_synth`),\n" +
"KEY `idx_computers_music_synth` (`music_synth`),\n" +
"KEY `idx_computers_hdd1` (`hdd1`),\n" +
"KEY `idx_computers_hdd2` (`hdd2`),\n" +
"KEY `idx_computers_hdd3` (`hdd3`),\n" +
"KEY `idx_computers_disk1` (`disk1`),\n" +
"KEY `idx_computers_disk2` (`disk2`),\n" +
"KEY `idx_computers_cap1` (`cap1`),\n" +
"KEY `idx_computers_cap2` (`cap2`),\n" +
"CONSTRAINT `fk_computers_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`),\n" +
"CONSTRAINT `fk_computers_cpu1` FOREIGN KEY (`cpu1`) REFERENCES `processors` (`id`),\n" +
"CONSTRAINT `fk_computers_cpu2` FOREIGN KEY (`cpu2`) REFERENCES `processors` (`id`),\n" +
"CONSTRAINT `fk_computers_disk1` FOREIGN KEY (`disk1`) REFERENCES `disk_formats` (`id`),\n" +
"CONSTRAINT `fk_computers_disk2` FOREIGN KEY (`disk2`) REFERENCES `disk_formats` (`id`),\n" +
"CONSTRAINT `fk_computers_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`),\n" +
"CONSTRAINT `fk_computers_hdd1` FOREIGN KEY (`hdd1`) REFERENCES `disk_formats` (`id`),\n" +
"CONSTRAINT `fk_computers_hdd2` FOREIGN KEY (`hdd2`) REFERENCES `disk_formats` (`id`),\n" +
"CONSTRAINT `fk_computers_hdd3` FOREIGN KEY (`hdd3`) REFERENCES `disk_formats` (`id`),\n" +
"CONSTRAINT `fk_computers_music_synth` FOREIGN KEY (`music_synth`) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE,\n" +
"CONSTRAINT `fk_computers_sound_synth` FOREIGN KEY (`sound_synth`) REFERENCES `sound_synths` (`id`));";
public static readonly string Consoles = V12.Consoles;
public static readonly string Consoles =
"CREATE TABLE `consoles` (\n" +
"`id` int(11) NOT NULL AUTO_INCREMENT,\n" +
"`company` int(11) NOT NULL DEFAULT '0',\n" +
"`model` char(50) NOT NULL DEFAULT '',\n" +
"`year` int(11) NOT NULL DEFAULT '0',\n" +
"`cpu1` int(11) DEFAULT NULL,\n" +
"`mhz1` int(11) DEFAULT NULL,\n" +
"`cpu2` int(11) DEFAULT NULL,\n" +
"`mhz2` decimal(11,2) DEFAULT NULL,\n" +
"`bits` int(11) NOT NULL DEFAULT '0',\n" +
"`ram` int(11) NOT NULL DEFAULT '0',\n" +
"`rom` int(11) NOT NULL DEFAULT '0',\n" +
"`gpu` int(11) DEFAULT NULL,\n" +
"`vram` int(11) NOT NULL DEFAULT '0',\n" +
"`res` char(11) NOT NULL DEFAULT '',\n" +
"`colors` int(11) NOT NULL DEFAULT '0',\n" +
"`palette` int(11) NOT NULL DEFAULT '0',\n" +
"`sound_synth` int(11) NOT NULL DEFAULT '0',\n" +
"`schannels` int(11) NOT NULL DEFAULT '0',\n" +
"`music_synth` int(11) NOT NULL DEFAULT '0',\n" +
"`mchannels` int(11) NOT NULL DEFAULT '0',\n" +
"`format` int(11) NOT NULL DEFAULT '0',\n" +
"`cap` int(11) NOT NULL DEFAULT '0',\n" +
"PRIMARY KEY (`id`),\n" +
"KEY `idx_consoles_company` (`company`),\n" +
"KEY `idx_consoles_year` (`year`),\n" +
"KEY `idx_consoles_model` (`model`),\n" +
"KEY `idx_consoles_cpu1` (`cpu1`),\n" +
"KEY `idx_consoles_cpu2` (`cpu2`),\n" +
"KEY `idx_consoles_mhz1` (`mhz1`),\n" +
"KEY `idx_consoles_mhz2` (`mhz2`),\n" +
"KEY `idx_consoles_bits` (`bits`),\n" +
"KEY `idx_consoles_ram` (`ram`),\n" +
"KEY `idx_consoles_rom` (`rom`),\n" +
"KEY `idx_consoles_gpu` (`gpu`),\n" +
"KEY `idx_consoles_vram` (`vram`),\n" +
"KEY `idx_consoles_colors` (`colors`),\n" +
"KEY `idx_consoles_res` (`res`),\n" +
"KEY `idx_consoles_sound_synth` (`sound_synth`),\n" +
"KEY `idx_consoles_music_synth` (`music_synth`),\n" +
"KEY `idx_consoles_palette` (`palette`),\n" +
"KEY `idx_consoles_format` (`format`),\n" +
"KEY `idx_consoles_cap` (`cap`),\n" +
"CONSTRAINT `fk_consoles_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`),\n" +
"CONSTRAINT `fk_consoles_cpu1` FOREIGN KEY (`cpu1`) REFERENCES `processors` (`id`),\n" +
"CONSTRAINT `fk_consoles_cpu2` FOREIGN KEY (`cpu2`) REFERENCES `processors` (`id`),\n" +
"CONSTRAINT `fk_consoles_format` FOREIGN KEY (`format`) REFERENCES `disk_formats` (`id`),\n" +
"CONSTRAINT `fk_consoles_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`),\n" +
"CONSTRAINT `fk_consoles_music_synth` FOREIGN KEY (`music_synth`) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE,\n" +
"CONSTRAINT `fk_consoles_sound_synth` FOREIGN KEY (`sound_synth`) REFERENCES `sound_synths` (`id`));";
public static readonly string DiskFormats = V12.DiskFormats;
@@ -59,8 +171,6 @@ namespace Cicm.Database.Schemas.Sql
public static readonly string MoneyDonations = V12.MoneyDonations;
public static readonly string MusicSynths = V12.MusicSynths;
public static readonly string News = V12.News;
public static readonly string OwnedComputers = V12.OwnedComputers;
@@ -69,7 +179,30 @@ namespace Cicm.Database.Schemas.Sql
public static readonly string Processors = V12.Processors;
public static readonly string SoundSynths = V12.SoundSynths;
public static readonly string SoundSynths = "CREATE TABLE `sound_synths` (\n" +
"`id` int(11) NOT NULL AUTO_INCREMENT,\n" +
"`name` char(50) NOT NULL DEFAULT '',\n" +
"`company` int(11) DEFAULT NULL,\n" +
"`model_code` varchar(45) DEFAULT NULL,\n" +
"`introduced` datetime DEFAULT NULL,\n" +
"`voices` int(11) DEFAULT NULL,\n" +
"`frequency` double DEFAULT NULL,\n" +
"`depth` int(11) DEFAULT NULL,\n" +
"`square_wave` int(11) DEFAULT NULL,\n" +
"`white_noise` int(11) DEFAULT NULL,\n" +
"`type` int(11) DEFAULT NULL,\n" +
"PRIMARY KEY (`id`),\n" +
"KEY `idx_sound_synths_name` (`name`),\n" +
"KEY `idx_sound_synths_company` (`company`),\n" +
"KEY `idx_sound_synths_model_code` (`model_code`),\n" +
"KEY `idx_sound_synths_introduced` (`introduced`),\n" +
"KEY `idx_sound_synths_voices` (`voices`),\n" +
"KEY `idx_sound_synths_frequency` (`frequency`),\n" +
"KEY `idx_sound_synths_depth` (`depth`),\n" +
"KEY `idx_sound_synths_square_wave` (`square_wave`),\n" +
"KEY `idx_sound_synths_white_noise` (`white_noise`),\n" +
"KEY `idx_sound_synths_type` (`type`),\n" +
"CONSTRAINT `fk_sound_synths_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE);";
public static readonly string ComputersForeignKeys = V12.ComputersForeignKeys;