Permalink
Browse files

+ Updated gitignore to not include packages folder that is added when…

… using

NuGet.
+ Removed id properties from Statistics kernel.
+ Added Fluent Migrator to Migrations project.
+ Added first migration that sets up database.
  • Loading branch information...
1 parent 9a5b7ff commit 2de8b615e0df2940c3542c14d85b9d7b01ccd6e4 @mslot committed Sep 13, 2012
View
@@ -26,6 +26,7 @@
[Bb]in
[Dd]ebug*/
obj/
+packages/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{FF09359B-C95C-445B-8E55-62053CE81C0C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>IRCSharp.Migrations</RootNamespace>
+ <AssemblyName>IRCSharp.Migrations</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <MigratorTasksDirectory>$(MSBuildProjectDirectory)\..\packages</MigratorTasksDirectory>
+ <ConnectionString>Data Source=C:/data/Statistics.db;Version=3;</ConnectionString>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="FluentMigrator">
+ <HintPath>..\packages\FluentMigrator.1.0.3.0\lib\40\FluentMigrator.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Statistics\InitDatabase.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <UsingTask TaskName="FluentMigrator.MSBuild.Migrate" AssemblyFile="$(MigratorTasksDirectory)\FluentMigrator.Tools.1.0.3.0\tools\AnyCPU\40\FluentMigrator.MSBuild.dll" />
+ <Target Name="Migrate">
+ <Message Text="Starting FluentMigrator Migration" />
+ <Migrate Database="sqlite" Connection="$(ConnectionString)" Target="$(MSBuildProjectDirectory)\bin\$(Configuration)\IRCSharp.Migrations.dll" Verbose="true">
+ </Migrate>
+ </Target>
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild" DependsOnTargets="Migrate">
+ </Target>
+</Project>
@@ -0,0 +1,36 @@
+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("Migrations")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Migrations")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[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("c00f8871-9108-4e48-8166-e6199ebc7a9c")]
+
+// 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")]
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FluentMigrator;
+
+namespace Migrations.Statistics
+{
+ [Migration(1)]
+ class InitDatabase : Migration
+ {
+ public override void Down()
+ {
+ Create.Table("User")
+ .WithColumn("nick").AsString()
+ .WithColumn("id").AsInt32()
+ .PrimaryKey()
+ .Unique()
+ .Indexed()
+ .Identity();
+
+ Create.Table("Channel")
+ .WithColumn("name").AsString()
+ .WithColumn("network").AsString()
+ .WithColumn("userId").AsInt32().NotNullable()
+ .WithColumn("id").AsInt32()
+ .PrimaryKey()
+ .Unique()
+ .Indexed()
+ .Identity();
+
+ Create.Table("Query")
+ .WithColumn("rawQuery").AsString()
+ .WithColumn("channelId").AsInt32().NotNullable()
+ .WithColumn("id").AsInt32()
+ .PrimaryKey()
+ .Unique()
+ .Indexed()
+ .Identity();
+
+ Create.ForeignKey("fk_channel_user").FromTable("Channel").ForeignColumn("userId").ToTable("User").PrimaryColumn("id");
+ Create.ForeignKey("fk_query_channel").FromTable("Query").ForeignColumn("channelId").ToTable("Channel").PrimaryColumn("id");
+ }
+
+ public override void Up()
+ {
+ Delete.Table("Query");
+ Delete.Table("Channel");
+ Delete.Table("User");
+ }
+ }
+}
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="FluentMigrator" version="1.0.3.0" targetFramework="net40" />
+ <package id="FluentMigrator.Tools" version="1.0.3.0" targetFramework="net40" />
+</packages>
@@ -50,11 +50,6 @@
<Compile Include="Repository\StatisticsRepository.cs" />
</ItemGroup>
<ItemGroup>
- <Content Include="Statistics.sdf">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- </ItemGroup>
- <ItemGroup>
<ProjectReference Include="..\IRCSharp.Kernel.Model\IRCSharp.Kernel.Model.csproj">
<Project>{8258F2F1-039A-4C9E-8046-7E7FC447DDB6}</Project>
<Name>IRCSharp.Kernel.Model</Name>
@@ -11,7 +11,6 @@ public class StatisticsManager
public StatisticsManager()
{
- //_databaseDal = new Dal.RavenDal(@"C:\data\testRavenDb", false);
}
public void AddQuery(IRCSharp.Kernel.Model.Query.IRCCommandQuery query)
@@ -8,15 +8,13 @@ namespace IRCSharp.Statistics.Kernel.Model
public class Channel : IEquatable<Channel>
{
public List<IRCSharp.Kernel.Model.Query.IRCCommandQuery> Queries = new List<IRCSharp.Kernel.Model.Query.IRCCommandQuery>();
- public string ChannelName { get; private set; }
+ public string Name { get; private set; }
public string Network { get; private set; } //TODO: implement network
- public string FullPath { get { return Network + "/" + ChannelName; } }
- public string Id { get; private set; }
+ public string FullPath { get { return Network + "/" + Name; } }
public Channel(string channelName)
{
- ChannelName = channelName;
- Id = FullPath;
+ Name = channelName;
}
public override bool Equals(object obj)
@@ -7,14 +7,12 @@ namespace IRCSharp.Statistics.Kernel.Model
{
public class User
{
- public string Id { get; private set; }
public List<Channel> Channels = new List<Channel>();
public string Nick { get; private set; }
public User(string nick)
{
Nick = nick;
- Id = Nick;
}
public void AddQuery(IRCSharp.Kernel.Model.Query.IRCCommandQuery query)
@@ -23,7 +21,7 @@ public void AddQuery(IRCSharp.Kernel.Model.Query.IRCCommandQuery query)
foreach (Channel channel in Channels)
{
- if (channel.ChannelName == query.To) //TODO: is To an channel? Is it a comma seperated list of channels and users?
+ if (channel.Name == query.To) //TODO: is To an channel? Is it a comma seperated list of channels and users?
{
channel.Queries.Add(query);
found = true;
Binary file not shown.
View
@@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRCSharp.Kernel.Model", "IR
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserdefinedCommandExample", "UserdefinedCommandExample\UserdefinedCommandExample.csproj", "{1C98734C-BE69-4373-80C6-5BCCF477B8A1}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRCSharp.Migrations", "IRCSharp.Migrations\IRCSharp.Migrations.csproj", "{FF09359B-C95C-445B-8E55-62053CE81C0C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -137,6 +139,16 @@ Global
{1C98734C-BE69-4373-80C6-5BCCF477B8A1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{1C98734C-BE69-4373-80C6-5BCCF477B8A1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{1C98734C-BE69-4373-80C6-5BCCF477B8A1}.Release|x86.ActiveCfg = Release|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {FF09359B-C95C-445B-8E55-62053CE81C0C}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -81,6 +81,12 @@ public IEnumerable<IRCSharp.Kernel.Model.Query.IRCCommandQuery> GenerateQueries(
}
+ [SetUp]
+ public void Setup()
+ {
+
+ }
+
[Test]
public void AddFirstGeneratedQueries()
{

0 comments on commit 2de8b61

Please sign in to comment.