From 3256a743d968418885c4a8bafa7dc4a472fafdf8 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Mon, 24 Oct 2016 10:33:19 +0100 Subject: [PATCH] Revert "Sorting out the current state of migrations" This reverts commit ac8e5320ef85973eaa8c409ed701406e6d8546b4. --- PlexRequests.Core.Migration/IMigration.cs | 36 --------- .../IMigrationRunner.cs | 7 -- PlexRequests.Core.Migration/Migrate.cs | 33 --------- .../MigrationAttribute.cs | 43 ----------- .../MigrationRunner.cs | 73 ------------------- .../Migrations/BaseMigration.cs | 40 ---------- .../Migrations/Version195.cs | 42 ----------- .../PlexRequests.Core.Migration.csproj | 70 ------------------ .../Properties/AssemblyInfo.cs | 36 --------- PlexRequests.Core/PlexRequests.Core.csproj | 4 - PlexRequests.Store/SqlTables.sql | 7 -- PlexRequests.Store/TableCreation.cs | 7 -- .../NinjectModules/ConfigurationModule.cs | 2 - PlexRequests.UI/PlexRequests.UI.csproj | 4 - PlexRequests.UI/Startup.cs | 5 -- PlexRequests.sln | 8 +- 16 files changed, 1 insertion(+), 416 deletions(-) delete mode 100644 PlexRequests.Core.Migration/IMigration.cs delete mode 100644 PlexRequests.Core.Migration/IMigrationRunner.cs delete mode 100644 PlexRequests.Core.Migration/Migrate.cs delete mode 100644 PlexRequests.Core.Migration/MigrationAttribute.cs delete mode 100644 PlexRequests.Core.Migration/MigrationRunner.cs delete mode 100644 PlexRequests.Core.Migration/Migrations/BaseMigration.cs delete mode 100644 PlexRequests.Core.Migration/Migrations/Version195.cs delete mode 100644 PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj delete mode 100644 PlexRequests.Core.Migration/Properties/AssemblyInfo.cs diff --git a/PlexRequests.Core.Migration/IMigration.cs b/PlexRequests.Core.Migration/IMigration.cs deleted file mode 100644 index d9579d56e..000000000 --- a/PlexRequests.Core.Migration/IMigration.cs +++ /dev/null @@ -1,36 +0,0 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: IMigration.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion - -using System.Data; - -namespace PlexRequests.Core.Migration -{ - public interface IMigration - { - void Start(IDbConnection con); - } -} \ No newline at end of file diff --git a/PlexRequests.Core.Migration/IMigrationRunner.cs b/PlexRequests.Core.Migration/IMigrationRunner.cs deleted file mode 100644 index 4ccd615e8..000000000 --- a/PlexRequests.Core.Migration/IMigrationRunner.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace PlexRequests.Core.Migration -{ - public interface IMigrationRunner - { - void MigrateToLatest(); - } -} \ No newline at end of file diff --git a/PlexRequests.Core.Migration/Migrate.cs b/PlexRequests.Core.Migration/Migrate.cs deleted file mode 100644 index e5266aa5b..000000000 --- a/PlexRequests.Core.Migration/Migrate.cs +++ /dev/null @@ -1,33 +0,0 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: Migrate.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion -namespace PlexRequests.Core.Migration -{ - public class Migrate - { - - } -} \ No newline at end of file diff --git a/PlexRequests.Core.Migration/MigrationAttribute.cs b/PlexRequests.Core.Migration/MigrationAttribute.cs deleted file mode 100644 index b117c1127..000000000 --- a/PlexRequests.Core.Migration/MigrationAttribute.cs +++ /dev/null @@ -1,43 +0,0 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: Migration.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion - -using System; - -namespace PlexRequests.Core.Migration -{ - [AttributeUsage(AttributeTargets.Class)] - public class Migration : Attribute - { - public Migration(int version, string description) - { - Version = version; - Description = description; - } - public int Version { get; private set; } - public string Description { get; private set; } - } -} \ No newline at end of file diff --git a/PlexRequests.Core.Migration/MigrationRunner.cs b/PlexRequests.Core.Migration/MigrationRunner.cs deleted file mode 100644 index 9d85cf485..000000000 --- a/PlexRequests.Core.Migration/MigrationRunner.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.Common; -using System.Linq; -using System.Reflection; -using PlexRequests.Store; - -namespace PlexRequests.Core.Migration -{ - public class MigrationRunner : IMigrationRunner - { - public MigrationRunner(ISqliteConfiguration db) - { - Db = db; - } - - private ISqliteConfiguration Db { get; } - - public void MigrateToLatest() - { - var con = Db.DbConnection(); - var versions = GetMigrations().OrderBy(x => x.Key); - - var dbVersion = con.GetSchemaVersion(); - - foreach (var v in versions) - { - if (v.Value.Version > dbVersion.SchemaVersion) - { - var method = v.Key.GetMethod("Start"); - if (method != null) - { - object result = null; - var classInstance = Activator.CreateInstance(v.Key, null); - - var parametersArray = new object[] { Db.DbConnection() }; - - method.Invoke(classInstance, parametersArray); - } - } - } - } - - private Dictionary GetMigrations() - { - var migrationTypes = GetTypesWithHelpAttribute(Assembly.GetAssembly(typeof(MigrationRunner))); - - var version = new Dictionary(); - - foreach (var t in migrationTypes) - { - var customAttributes = (Migration[])t.GetCustomAttributes(typeof(Migration), true); - if (customAttributes.Length > 0) - { - var attr = customAttributes[0]; - - version.Add(t, new MigrationModel { Version = attr.Version, Description = attr.Description }); - } - } - return version; - } - private static IEnumerable GetTypesWithHelpAttribute(Assembly assembly) - { - return assembly.GetTypes().Where(type => type.GetCustomAttributes(typeof(Migration), true).Length > 0); - } - - private class MigrationModel - { - public int Version { get; set; } - public string Description { get; set; } - } - } -} diff --git a/PlexRequests.Core.Migration/Migrations/BaseMigration.cs b/PlexRequests.Core.Migration/Migrations/BaseMigration.cs deleted file mode 100644 index 9df877682..000000000 --- a/PlexRequests.Core.Migration/Migrations/BaseMigration.cs +++ /dev/null @@ -1,40 +0,0 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: BaseMigration.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion - -using System.Data; -using System.Data.Common; - -namespace PlexRequests.Core.Migration.Migrations -{ - public abstract class BaseMigration - { - protected void UpdateSchema(IDbConnection con) - { - - } - } -} \ No newline at end of file diff --git a/PlexRequests.Core.Migration/Migrations/Version195.cs b/PlexRequests.Core.Migration/Migrations/Version195.cs deleted file mode 100644 index b1f4921fc..000000000 --- a/PlexRequests.Core.Migration/Migrations/Version195.cs +++ /dev/null @@ -1,42 +0,0 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: Version195.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion - -using System.Data; - -namespace PlexRequests.Core.Migration.Migrations -{ - [Migration(1950, "v1.9.5.0")] - public class Version195 : BaseMigration, IMigration - { - public void Start(IDbConnection con) - { - - - UpdateSchema(con); - } - } -} \ No newline at end of file diff --git a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj b/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj deleted file mode 100644 index db1f55060..000000000 --- a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj +++ /dev/null @@ -1,70 +0,0 @@ - - - - - Debug - AnyCPU - {8406EE57-D533-47C0-9302-C6B5F8C31E55} - Library - Properties - PlexRequests.Core.Migration - PlexRequests.Core.Migration - v4.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\Assemblies\Mono.Data.Sqlite.dll - - - - - - - - - - - - - - - - - - - - - - - {92433867-2B7B-477B-A566-96C382427525} - PlexRequests.Store - - - - - \ No newline at end of file diff --git a/PlexRequests.Core.Migration/Properties/AssemblyInfo.cs b/PlexRequests.Core.Migration/Properties/AssemblyInfo.cs deleted file mode 100644 index 6e44d89b7..000000000 --- a/PlexRequests.Core.Migration/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PlexRequests.Core.Migration")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PlexRequests.Core.Migration")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8406ee57-d533-47c0-9302-c6b5f8c31e55")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PlexRequests.Core/PlexRequests.Core.csproj b/PlexRequests.Core/PlexRequests.Core.csproj index af40d401d..143508e1e 100644 --- a/PlexRequests.Core/PlexRequests.Core.csproj +++ b/PlexRequests.Core/PlexRequests.Core.csproj @@ -133,10 +133,6 @@ {8CB8D235-2674-442D-9C6A-35FCAEEB160D} PlexRequests.Api - - {8406ee57-d533-47c0-9302-c6b5f8c31e55} - PlexRequests.Core.Migration - {1252336D-42A3-482A-804C-836E60173DFA} PlexRequests.Helpers diff --git a/PlexRequests.Store/SqlTables.sql b/PlexRequests.Store/SqlTables.sql index ef3754069..74f31d0be 100644 --- a/PlexRequests.Store/SqlTables.sql +++ b/PlexRequests.Store/SqlTables.sql @@ -59,13 +59,6 @@ CREATE TABLE IF NOT EXISTS DBInfo SchemaVersion INTEGER ); -CREATE TABLE IF NOT EXISTS VersionInfo -( - Version INTEGER NOT NULL, - Description VARCHAR(100) NOT NULL -); - - CREATE TABLE IF NOT EXISTS ScheduledJobs ( Id INTEGER PRIMARY KEY AUTOINCREMENT, diff --git a/PlexRequests.Store/TableCreation.cs b/PlexRequests.Store/TableCreation.cs index 836a36c54..3e6336deb 100644 --- a/PlexRequests.Store/TableCreation.cs +++ b/PlexRequests.Store/TableCreation.cs @@ -117,13 +117,6 @@ namespace PlexRequests.Store public int SchemaVersion { get; set; } } - [Table("VersionInfo")] - public class VersionInfo - { - public int Version { get; set; } - public string Description { get; set; } - } - [Table("sqlite_master")] public class SqliteMasterTable { diff --git a/PlexRequests.UI/NinjectModules/ConfigurationModule.cs b/PlexRequests.UI/NinjectModules/ConfigurationModule.cs index 57cb76235..1382fd9c1 100644 --- a/PlexRequests.UI/NinjectModules/ConfigurationModule.cs +++ b/PlexRequests.UI/NinjectModules/ConfigurationModule.cs @@ -32,7 +32,6 @@ using Nancy.Authentication.Forms; using Ninject.Modules; using PlexRequests.Core; -using PlexRequests.Core.Migration; using PlexRequests.Helpers; using PlexRequests.Services.Interfaces; using PlexRequests.Services.Notification; @@ -48,7 +47,6 @@ namespace PlexRequests.UI.NinjectModules Bind().To().WithConstructorArgument("provider", new SqliteFactory()); Bind().To().WithConstructorArgument("provider", new SqliteFactory()); Bind().To(); - Bind().To(); Bind().To(); diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index d51e3a499..6c377cad6 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -754,10 +754,6 @@ {8CB8D235-2674-442D-9C6A-35FCAEEB160D} PlexRequests.Api - - {8406EE57-D533-47C0-9302-C6B5F8C31E55} - PlexRequests.Core.Migration - {DD7DC444-D3BF-4027-8AB9-EFC71F5EC581} PlexRequests.Core diff --git a/PlexRequests.UI/Startup.cs b/PlexRequests.UI/Startup.cs index 992e62bc2..c61f8766b 100644 --- a/PlexRequests.UI/Startup.cs +++ b/PlexRequests.UI/Startup.cs @@ -32,9 +32,7 @@ using Ninject.Planning.Bindings.Resolvers; using NLog; using Owin; -using PlexRequests.Core.Migration; using PlexRequests.Services.Jobs; -using PlexRequests.Store; using PlexRequests.UI.Helpers; using PlexRequests.UI.Jobs; using PlexRequests.UI.NinjectModules; @@ -69,9 +67,6 @@ namespace PlexRequests.UI Debug.WriteLine("Finished bootstrapper"); var scheduler = new Scheduler(); scheduler.StartScheduler(); - - var db = kernel.Get(); - db.MigrateToLatest(); } catch (Exception exception) { diff --git a/PlexRequests.sln b/PlexRequests.sln index 831a31b25..ec6287fad 100644 --- a/PlexRequests.sln +++ b/PlexRequests.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.UI", "PlexRequests.UI\PlexRequests.UI.csproj", "{68F5F5F3-B8BB-4911-875F-6F00AAE04EA6}" EndProject @@ -45,8 +45,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Automation.Pag EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequestes.Automation.Helpers", "PlexRequestes.Automation.Helpers\PlexRequestes.Automation.Helpers.csproj", "{DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Core.Migration", "PlexRequests.Core.Migration\PlexRequests.Core.Migration.csproj", "{8406EE57-D533-47C0-9302-C6B5F8C31E55}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -110,10 +108,6 @@ Global {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}.Debug|Any CPU.Build.0 = Debug|Any CPU {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8406EE57-D533-47C0-9302-C6B5F8C31E55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8406EE57-D533-47C0-9302-C6B5F8C31E55}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8406EE57-D533-47C0-9302-C6B5F8C31E55}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8406EE57-D533-47C0-9302-C6B5F8C31E55}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE