got basic relationships working

added support for embedded documents.
This commit is contained in:
kay.one 2013-03-25 22:51:56 -07:00
commit fc641baab3
51 changed files with 359 additions and 127 deletions

View file

@ -1,7 +1,7 @@
using System.Reflection;
using FluentMigrator.Runner;
using FluentMigrator.Runner.Initialization;
using NzbDrone.Core.Datastore.Migration.Sqlite;
using FluentMigrator.Runner.Processors.Sqlite;
namespace NzbDrone.Core.Datastore.Migration.Framework
{
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new MonoSqliteProcessorFactory();
var factory = new SqliteProcessorFactory();
var processor = factory.Create(connectionString, _announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);

View file

@ -1,5 +1,5 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Datastore.Migration
Create.Table("Episodes")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("TvdbId").AsInt32().Nullable()
.WithColumn("TvDbEpisodeId").AsInt32().Nullable()
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("SeasonNumber").AsInt32().NotNullable()
.WithColumn("EpisodeNumber").AsInt32().NotNullable()
@ -56,8 +56,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("NzbTitle").AsString().NotNullable()
.WithColumn("Date").AsDateTime().NotNullable()
.WithColumn("Quality").AsInt32().NotNullable()
.WithColumn("Proper").AsBoolean().NotNullable()
.WithColumn("Quality").AsString().NotNullable()
.WithColumn("Indexer").AsString().NotNullable()
.WithColumn("NzbInfoUrl").AsString().Nullable()
.WithColumn("ReleaseGroup").AsString().Nullable();
@ -131,7 +130,6 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("LastInfoSync").AsDateTime().Nullable()
.WithColumn("LastDiskSync").AsDateTime().Nullable()
.WithColumn("Runtime").AsInt32().NotNullable()
.WithColumn("BannerUrl").AsString().NotNullable()
.WithColumn("SeriesType").AsInt32().NotNullable()
.WithColumn("BacklogSetting").AsInt32().NotNullable()
.WithColumn("Network").AsString().NotNullable()
@ -140,7 +138,14 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("TvRageId").AsInt32().Nullable()
.WithColumn("TvRageTitle").AsString().NotNullable()
.WithColumn("UtcOffSet").AsInt32().NotNullable()
.WithColumn("FirstAired").AsDateTime().Nullable();
.WithColumn("FirstAired").AsDateTime().Nullable()
.WithColumn("NextAiring").AsDateTime().Nullable();
Create.Table("MediaCovers")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("Url").AsString().NotNullable()
.WithColumn("CoverType").AsInt32().NotNullable();
}
protected override void LogDbUpgrade()

View file

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentMigrator.Runner.Processors;
namespace NzbDrone.Core.Datastore.Migration.Sqlite
{
public class MonoSqliteDbFactory : ReflectionBasedDbFactory
{
public MonoSqliteDbFactory()
: base("Mono.Data.Sqlite", "Mono.Data.Sqlite.SqliteFactory")
{
}
}
}

View file

@ -1,18 +0,0 @@
using FluentMigrator;
using FluentMigrator.Runner;
using FluentMigrator.Runner.Generators.SQLite;
using FluentMigrator.Runner.Processors;
using FluentMigrator.Runner.Processors.Sqlite;
namespace NzbDrone.Core.Datastore.Migration.Sqlite
{
public class MonoSqliteProcessorFactory : MigrationProcessorFactory
{
public override IMigrationProcessor Create(string connectionString, IAnnouncer announcer, IMigrationProcessorOptions options)
{
var factory = new MonoSqliteDbFactory();
var connection = factory.CreateConnection(connectionString);
return new SqliteProcessor(connection, new SqliteGenerator(), announcer, options, factory);
}
}
}