From f4ba6ca55ea74aa1413fc584a7505901e377b59c Mon Sep 17 00:00:00 2001 From: Benjamin Ifland Date: Sat, 16 Mar 2019 17:00:13 +0100 Subject: [PATCH] init database --- API/API/API.csproj | 18 +++ API/API/Database/DataContext.cs | 11 ++ API/API/Database/Model/Access.cs | 8 ++ API/API/Database/Model/Change.cs | 11 ++ API/API/Database/Model/File.cs | 10 ++ API/API/Database/Model/FileType.cs | 8 ++ API/API/Database/Model/Song.cs | 17 +++ API/API/Database/Model/SongType.cs | 7 + API/API/Database/Model/User.cs | 11 ++ .../201903161558469_Init.Designer.cs | 29 ++++ API/API/Migrations/201903161558469_Init.cs | 71 ++++++++++ API/API/Migrations/201903161558469_Init.resx | 126 ++++++++++++++++++ API/API/Migrations/Configuration.cs | 9 ++ 13 files changed, 336 insertions(+) create mode 100644 API/API/Database/DataContext.cs create mode 100644 API/API/Database/Model/Access.cs create mode 100644 API/API/Database/Model/Change.cs create mode 100644 API/API/Database/Model/File.cs create mode 100644 API/API/Database/Model/FileType.cs create mode 100644 API/API/Database/Model/Song.cs create mode 100644 API/API/Database/Model/SongType.cs create mode 100644 API/API/Database/Model/User.cs create mode 100644 API/API/Migrations/201903161558469_Init.Designer.cs create mode 100644 API/API/Migrations/201903161558469_Init.cs create mode 100644 API/API/Migrations/201903161558469_Init.resx create mode 100644 API/API/Migrations/Configuration.cs diff --git a/API/API/API.csproj b/API/API/API.csproj index 73c8c00..41f149d 100644 --- a/API/API/API.csproj +++ b/API/API/API.csproj @@ -101,9 +101,22 @@ + + + + + + + + Global.asax + + + 201903161558469_Init.cs + + @@ -123,6 +136,11 @@ + + + 201903161558469_Init.cs + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/API/API/Database/DataContext.cs b/API/API/Database/DataContext.cs new file mode 100644 index 0000000..1543164 --- /dev/null +++ b/API/API/Database/DataContext.cs @@ -0,0 +1,11 @@ +using API.Database.Model; +using System.Data.Entity; + +namespace API.Database { + public class DataContext : DbContext { + public DbSet Songs { get; set; } + public DbSet Changes { get; set; } + public DbSet Files { get; set; } + public DbSet Users { get; set; } + } +} \ No newline at end of file diff --git a/API/API/Database/Model/Access.cs b/API/API/Database/Model/Access.cs new file mode 100644 index 0000000..6cf873f --- /dev/null +++ b/API/API/Database/Model/Access.cs @@ -0,0 +1,8 @@ +namespace API.Database.Model { + public enum Access { + Inactive, + Reader, + Writer, + Admin + } +} \ No newline at end of file diff --git a/API/API/Database/Model/Change.cs b/API/API/Database/Model/Change.cs new file mode 100644 index 0000000..2c5c5bd --- /dev/null +++ b/API/API/Database/Model/Change.cs @@ -0,0 +1,11 @@ +using System; + +namespace API.Database.Model { + public class Change { + public int ID { get; set; } + public int UserId { get; set; } + public User User { get; set; } + public DateTime Date { get; set; } + public string Comment { get; set; } + } +} \ No newline at end of file diff --git a/API/API/Database/Model/File.cs b/API/API/Database/Model/File.cs new file mode 100644 index 0000000..b6f2c83 --- /dev/null +++ b/API/API/Database/Model/File.cs @@ -0,0 +1,10 @@ +using System; + +namespace API.Database.Model { + public class File { + public int ID { get; set; } + public Guid ReferenceFile { get; set; } + public string Name { get; set; } + public FileType FileType { get; set; } + } +} \ No newline at end of file diff --git a/API/API/Database/Model/FileType.cs b/API/API/Database/Model/FileType.cs new file mode 100644 index 0000000..5843865 --- /dev/null +++ b/API/API/Database/Model/FileType.cs @@ -0,0 +1,8 @@ +namespace API.Database.Model { + public enum FileType { + None, + Sheet, + Chords, + MuseScore + } +} \ No newline at end of file diff --git a/API/API/Database/Model/Song.cs b/API/API/Database/Model/Song.cs new file mode 100644 index 0000000..a733681 --- /dev/null +++ b/API/API/Database/Model/Song.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace API.Database.Model { + public class Song { + public int ID { get; set; } + public string Name { get; set; } + public string Text { get; set; } + public string Comments { get; set; } + public string Key { get; set; } + public int? Tempo { get; set; } + public SongType SongType { get; set; } + + public bool Final { get; set; } + + public virtual ICollection Changes { get; set; } + } +} \ No newline at end of file diff --git a/API/API/Database/Model/SongType.cs b/API/API/Database/Model/SongType.cs new file mode 100644 index 0000000..551f0ea --- /dev/null +++ b/API/API/Database/Model/SongType.cs @@ -0,0 +1,7 @@ +namespace API.Database.Model { + public enum SongType { + Praise, + Worship + } + +} \ No newline at end of file diff --git a/API/API/Database/Model/User.cs b/API/API/Database/Model/User.cs new file mode 100644 index 0000000..b9371a1 --- /dev/null +++ b/API/API/Database/Model/User.cs @@ -0,0 +1,11 @@ +namespace API.Database.Model { + public class User { + public int ID { get; set; } + public string Account { get; set; } + public string Pass { get; set; } + public string Name { get; set; } + public string Surname { get; set; } + public string Email { get; set; } + public Access Access { get; set; } + } +} \ No newline at end of file diff --git a/API/API/Migrations/201903161558469_Init.Designer.cs b/API/API/Migrations/201903161558469_Init.Designer.cs new file mode 100644 index 0000000..6a25edd --- /dev/null +++ b/API/API/Migrations/201903161558469_Init.Designer.cs @@ -0,0 +1,29 @@ +// +namespace API.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")] + public sealed partial class Init : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(Init)); + + string IMigrationMetadata.Id + { + get { return "201903161558469_Init"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/API/API/Migrations/201903161558469_Init.cs b/API/API/Migrations/201903161558469_Init.cs new file mode 100644 index 0000000..2d5440b --- /dev/null +++ b/API/API/Migrations/201903161558469_Init.cs @@ -0,0 +1,71 @@ +namespace API.Migrations { + using System.Data.Entity.Migrations; + + public partial class Init : DbMigration { + public override void Up() { + CreateTable( + "dbo.Changes", + c => new { + ID = c.Int(nullable: false, identity: true), + UserId = c.Int(nullable: false), + Date = c.DateTime(nullable: false), + Comment = c.String(), + Song_ID = c.Int(), + }) + .PrimaryKey(t => t.ID) + .ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true) + .ForeignKey("dbo.Songs", t => t.Song_ID) + .Index(t => t.UserId) + .Index(t => t.Song_ID); + + CreateTable( + "dbo.Users", + c => new { + ID = c.Int(nullable: false, identity: true), + Account = c.String(), + Pass = c.String(), + Name = c.String(), + Surname = c.String(), + Email = c.String(), + Access = c.Int(nullable: false), + }) + .PrimaryKey(t => t.ID); + + CreateTable( + "dbo.Files", + c => new { + ID = c.Int(nullable: false, identity: true), + ReferenceFile = c.Guid(nullable: false), + Name = c.String(), + FileType = c.Int(nullable: false), + }) + .PrimaryKey(t => t.ID); + + CreateTable( + "dbo.Songs", + c => new { + ID = c.Int(nullable: false, identity: true), + Name = c.String(), + Text = c.String(), + Comments = c.String(), + Key = c.String(), + Tempo = c.Int(), + SongType = c.Int(nullable: false), + Final = c.Boolean(nullable: false), + }) + .PrimaryKey(t => t.ID); + + } + + public override void Down() { + DropForeignKey("dbo.Changes", "Song_ID", "dbo.Songs"); + DropForeignKey("dbo.Changes", "UserId", "dbo.Users"); + DropIndex("dbo.Changes", new[] { "Song_ID" }); + DropIndex("dbo.Changes", new[] { "UserId" }); + DropTable("dbo.Songs"); + DropTable("dbo.Files"); + DropTable("dbo.Users"); + DropTable("dbo.Changes"); + } + } +} diff --git a/API/API/Migrations/201903161558469_Init.resx b/API/API/Migrations/201903161558469_Init.resx new file mode 100644 index 0000000..de31baa --- /dev/null +++ b/API/API/Migrations/201903161558469_Init.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1bW2/bNhR+H7D/IO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HrSAsSh2PATtRrSdV0+J4Ona+mjPypjeClYsYWWsZjTCjxP/z4LkyJv99klS7XmXGYj3yNv3/hrUPxbBb/4M/WP0AWXhPcp+SNDjjypYp16Yyhj7saIka+OFvXK/rrCvQ8uMzqxBclK7rwYBqb0CwzRH76IahKV1Sg1C0ruhCrE+YxfU16GXzk6knJI/ckwKzDsiEs8DupIGidDsPHpGIdpPmf+tEJ+N3WpfzyAgs3dnEJjSnzPwdEoPjqFJXe/HfsroUmilD+eWbKrNm5WsZRFplzVls360UYl8o8J0S4J3S6Xor6j8PLTevGtBt2SyPqegVzzfn13S7gK8XYxrSSrqL7r2Crt88sJD5VZ4UOmv2kqgrvJ7a/XdBewuJrsK8611eRdsWcnvULJvrdi7YJ215C0W81V2NkWp9bV7R/n6yyrYWxX6rR+qR0nezhaB0Sr/CyT4C0YWDYTIf1EcauZaz5nRu7RyG8aOqilG3HCOOYrAlo8zCMlRyOGzeNwUzcplr9tpcoujGb3M+TLncGSc3MZaill4n1XrF30H+p7Hl8uiu/c5jgDbJCLPcUnf5CSO6n2fOcKeFgjh1sq4WciSi/h58VQjybbNLkAl+2pvLELDGMDYJZ0jpQe3x97ACt/hBQqfqqRfO8h6QehsH58QtMhQwkqMhh7+BB2OksdX/wHka3UgCTwAAA== + + + dbo + + \ No newline at end of file diff --git a/API/API/Migrations/Configuration.cs b/API/API/Migrations/Configuration.cs new file mode 100644 index 0000000..6e5dc5f --- /dev/null +++ b/API/API/Migrations/Configuration.cs @@ -0,0 +1,9 @@ +namespace API.Migrations { + using System.Data.Entity.Migrations; + + internal sealed class Configuration : DbMigrationsConfiguration { + public Configuration() { + AutomaticMigrationsEnabled = false; + } + } +}