mirror of
https://github.com/bitwarden/server.git
synced 2024-11-24 12:35:25 +01:00
Added Sql project with database schema. Added SqlServer repositories for Site, Folder, and User (Cipher still TODO). Switched DI in Startup to SqlServer repos.
This commit is contained in:
parent
78fcad8c69
commit
13f85bf2f1
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}"
|
||||
EndProject
|
||||
@ -17,6 +17,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Core", "src\Core\Core.xproj
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Api", "src\Api\Api.xproj", "{E8548AD6-7FB0-439A-8EB5-549A10336D2D}"
|
||||
EndProject
|
||||
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "Sql", "src\Sql\Sql.sqlproj", "{58554E52-FDEC-4832-AFF9-302B01E08DCA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -31,6 +33,12 @@ Global
|
||||
{E8548AD6-7FB0-439A-8EB5-549A10336D2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E8548AD6-7FB0-439A-8EB5-549A10336D2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E8548AD6-7FB0-439A-8EB5-549A10336D2D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{58554E52-FDEC-4832-AFF9-302B01E08DCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{58554E52-FDEC-4832-AFF9-302B01E08DCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{58554E52-FDEC-4832-AFF9-302B01E08DCA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{58554E52-FDEC-4832-AFF9-302B01E08DCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{58554E52-FDEC-4832-AFF9-302B01E08DCA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{58554E52-FDEC-4832-AFF9-302B01E08DCA}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -38,5 +46,6 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{3973D21B-A692-4B60-9B70-3631C057423A} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}
|
||||
{E8548AD6-7FB0-439A-8EB5-549A10336D2D} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}
|
||||
{58554E52-FDEC-4832-AFF9-302B01E08DCA} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -14,9 +14,8 @@ using Bit.Core;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Identity;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Repositories.DocumentDB.Utilities;
|
||||
using Bit.Core.Services;
|
||||
using Repos = Bit.Core.Repositories.DocumentDB;
|
||||
using Repos = Bit.Core.Repositories.SqlServer;
|
||||
|
||||
namespace Bit.Api
|
||||
{
|
||||
@ -53,11 +52,10 @@ namespace Bit.Api
|
||||
services.AddSingleton(s => globalSettings);
|
||||
|
||||
// Repositories
|
||||
var documentDBClient = DocumentDBHelpers.InitClient(globalSettings.DocumentDB);
|
||||
services.AddSingleton<IUserRepository>(s => new Repos.UserRepository(documentDBClient, globalSettings.DocumentDB.DatabaseId));
|
||||
services.AddSingleton<ISiteRepository>(s => new Repos.SiteRepository(documentDBClient, globalSettings.DocumentDB.DatabaseId));
|
||||
services.AddSingleton<IFolderRepository>(s => new Repos.FolderRepository(documentDBClient, globalSettings.DocumentDB.DatabaseId));
|
||||
services.AddSingleton<ICipherRepository>(s => new Repos.CipherRepository(documentDBClient, globalSettings.DocumentDB.DatabaseId));
|
||||
services.AddSingleton<IUserRepository>(s => new Repos.UserRepository(globalSettings.SqlServer.ConnectionString));
|
||||
services.AddSingleton<ISiteRepository>(s => new Repos.SiteRepository(globalSettings.SqlServer.ConnectionString));
|
||||
services.AddSingleton<IFolderRepository>(s => new Repos.FolderRepository(globalSettings.SqlServer.ConnectionString));
|
||||
services.AddSingleton<ICipherRepository>(s => new Repos.CipherRepository(globalSettings.SqlServer.ConnectionString));
|
||||
|
||||
// Context
|
||||
services.AddScoped<CurrentContext>();
|
||||
|
@ -9,6 +9,9 @@
|
||||
"collectionIdPrefix": "SECRET",
|
||||
"numberOfCollections": 1
|
||||
},
|
||||
"sqlServer": {
|
||||
"connectionString": "SECRET"
|
||||
},
|
||||
"mail": {
|
||||
"apiKey": "SECRET",
|
||||
"replyToEmail": "do-not-reply@bitwarden.com"
|
||||
|
@ -5,9 +5,10 @@ namespace Bit.Core
|
||||
{
|
||||
public class GlobalSettings
|
||||
{
|
||||
public string SiteName { get; set; }
|
||||
public string BaseVaultUri { get; set; }
|
||||
public virtual string SiteName { get; set; }
|
||||
public virtual string BaseVaultUri { get; set; }
|
||||
public virtual DocumentDBSettings DocumentDB { get; set; } = new DocumentDBSettings();
|
||||
public virtual SqlServerSettings SqlServer { get; set; } = new SqlServerSettings();
|
||||
public virtual MailSettings Mail { get; set; } = new MailSettings();
|
||||
|
||||
public class DocumentDBSettings
|
||||
@ -19,6 +20,11 @@ namespace Bit.Core
|
||||
public int NumberOfCollections { get; set; }
|
||||
}
|
||||
|
||||
public class SqlServerSettings
|
||||
{
|
||||
public string ConnectionString { get; set; }
|
||||
}
|
||||
|
||||
public class MailSettings
|
||||
{
|
||||
public string APIKey { get; set; }
|
||||
|
27
src/Core/Repositories/SqlServer/CipherRepository.cs
Normal file
27
src/Core/Repositories/SqlServer/CipherRepository.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public class CipherRepository : ICipherRepository
|
||||
{
|
||||
public CipherRepository(string connectionString)
|
||||
{ }
|
||||
|
||||
public Task DirtyCiphersAsync(string userId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task UpdateDirtyCiphersAsync(IEnumerable<dynamic> ciphers)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task CreateAsync(IEnumerable<dynamic> ciphers)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
47
src/Core/Repositories/SqlServer/FolderRepository.cs
Normal file
47
src/Core/Repositories/SqlServer/FolderRepository.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Repositories.SqlServer.Models;
|
||||
using Dapper;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public class FolderRepository : Repository<Folder, FolderTableModel>, IFolderRepository
|
||||
{
|
||||
public FolderRepository(string connectionString)
|
||||
: base(connectionString)
|
||||
{ }
|
||||
|
||||
public async Task<Folder> GetByIdAsync(string id, string userId)
|
||||
{
|
||||
var folder = await GetByIdAsync(id);
|
||||
if(folder == null || folder.UserId != userId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
public async Task<ICollection<Folder>> GetManyByUserIdAsync(string userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<FolderTableModel>(
|
||||
$"[{Schema}].[{Table}_ReadByUserId]",
|
||||
new { UserId = userId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.Select(f => f.ToDomain()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Folder>> GetManyByUserIdAsync(string userId, bool dirty)
|
||||
{
|
||||
return await GetManyByUserIdAsync(userId);
|
||||
}
|
||||
}
|
||||
}
|
37
src/Core/Repositories/SqlServer/Models/FolderTableModel.cs
Normal file
37
src/Core/Repositories/SqlServer/Models/FolderTableModel.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer.Models
|
||||
{
|
||||
public class FolderTableModel : ITableModel<Folder>
|
||||
{
|
||||
public FolderTableModel() { }
|
||||
|
||||
public FolderTableModel(Folder folder)
|
||||
{
|
||||
Id = new Guid(folder.Id);
|
||||
UserId = new Guid(folder.UserId);
|
||||
Name = folder.Name;
|
||||
CreationDate = folder.CreationDate;
|
||||
RevisionDate = folder.RevisionDate;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
|
||||
public Folder ToDomain()
|
||||
{
|
||||
return new Folder
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
UserId = UserId.ToString(),
|
||||
Name = Name,
|
||||
CreationDate = CreationDate,
|
||||
RevisionDate = RevisionDate
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
7
src/Core/Repositories/SqlServer/Models/ITableModel.cs
Normal file
7
src/Core/Repositories/SqlServer/Models/ITableModel.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Bit.Core.Repositories.SqlServer.Models
|
||||
{
|
||||
public interface ITableModel<T>
|
||||
{
|
||||
T ToDomain();
|
||||
}
|
||||
}
|
52
src/Core/Repositories/SqlServer/Models/SiteTableModel.cs
Normal file
52
src/Core/Repositories/SqlServer/Models/SiteTableModel.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer.Models
|
||||
{
|
||||
public class SiteTableModel : ITableModel<Site>
|
||||
{
|
||||
public SiteTableModel() { }
|
||||
|
||||
public SiteTableModel(Site site)
|
||||
{
|
||||
Id = new Guid(site.Id);
|
||||
UserId = new Guid(site.UserId);
|
||||
FolderId = string.IsNullOrWhiteSpace(site.FolderId) ? (Guid?)null : new Guid(site.FolderId);
|
||||
Name = site.Name;
|
||||
Uri = site.Uri;
|
||||
Username = site.Username;
|
||||
Password = site.Password;
|
||||
Notes = site.Notes;
|
||||
CreationDate = site.CreationDate;
|
||||
RevisionDate = site.RevisionDate;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid? FolderId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Uri { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
|
||||
public Site ToDomain()
|
||||
{
|
||||
return new Site
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
UserId = UserId.ToString(),
|
||||
FolderId = FolderId.ToString(),
|
||||
Name = Name,
|
||||
Uri = Uri,
|
||||
Username = Username,
|
||||
Password = Password,
|
||||
Notes = Notes,
|
||||
CreationDate = CreationDate,
|
||||
RevisionDate = RevisionDate
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
56
src/Core/Repositories/SqlServer/Models/UserTableModel.cs
Normal file
56
src/Core/Repositories/SqlServer/Models/UserTableModel.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer.Models
|
||||
{
|
||||
public class UserTableModel : ITableModel<User>
|
||||
{
|
||||
public UserTableModel() { }
|
||||
|
||||
public UserTableModel(User user)
|
||||
{
|
||||
Id = new Guid(user.Id);
|
||||
Name = user.Name;
|
||||
Email = user.Email;
|
||||
MasterPassword = user.MasterPassword;
|
||||
MasterPasswordHint = user.MasterPasswordHint;
|
||||
Culture = user.Culture;
|
||||
SecurityStamp = user.SecurityStamp;
|
||||
TwoFactorEnabled = user.TwoFactorEnabled;
|
||||
TwoFactorProvider = user.TwoFactorProvider;
|
||||
AuthenticatorKey = user.AuthenticatorKey;
|
||||
CreationDate = user.CreationDate;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string MasterPassword { get; set; }
|
||||
public string MasterPasswordHint { get; set; }
|
||||
public string Culture { get; set; }
|
||||
public string SecurityStamp { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public TwoFactorProvider? TwoFactorProvider { get; set; }
|
||||
public string AuthenticatorKey { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
|
||||
public User ToDomain()
|
||||
{
|
||||
return new User
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
Name = Name,
|
||||
Email = Email,
|
||||
MasterPassword = MasterPassword,
|
||||
MasterPasswordHint = MasterPasswordHint,
|
||||
Culture = Culture,
|
||||
SecurityStamp = SecurityStamp,
|
||||
TwoFactorEnabled = TwoFactorEnabled,
|
||||
TwoFactorProvider = TwoFactorProvider,
|
||||
AuthenticatorKey = AuthenticatorKey,
|
||||
CreationDate = CreationDate
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
111
src/Core/Repositories/SqlServer/Repository.cs
Normal file
111
src/Core/Repositories/SqlServer/Repository.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Repositories.SqlServer.Models;
|
||||
using Dapper;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public abstract class Repository<T, TModel> : IRepository<T> where T : IDataObject where TModel : ITableModel<T>
|
||||
{
|
||||
public Repository(string connectionString, string schema = null, string table = null)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(connectionString));
|
||||
}
|
||||
|
||||
ConnectionString = connectionString;
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(table))
|
||||
{
|
||||
Table = table;
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(schema))
|
||||
{
|
||||
Schema = schema;
|
||||
}
|
||||
}
|
||||
|
||||
protected string ConnectionString { get; private set; }
|
||||
protected string Schema { get; private set; } = "dbo";
|
||||
protected string Table { get; private set; } = typeof(T).Name;
|
||||
|
||||
public virtual async Task<T> GetByIdAsync(string id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<TModel>(
|
||||
$"[{Schema}].[{Table}_ReadById]",
|
||||
new { Id = id },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
var model = results.FirstOrDefault();
|
||||
if(model == null)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
return model.ToDomain();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task CreateAsync(T obj)
|
||||
{
|
||||
obj.Id = Guid.NewGuid().ToString();
|
||||
var tableModel = (TModel)Activator.CreateInstance(typeof(TModel), obj);
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_Create]",
|
||||
tableModel,
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task ReplaceAsync(T obj)
|
||||
{
|
||||
var tableModel = (TModel)Activator.CreateInstance(typeof(TModel), obj);
|
||||
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_Update]",
|
||||
tableModel,
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task UpsertAsync(T obj)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(obj.Id))
|
||||
{
|
||||
await CreateAsync(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplaceAsync(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task DeleteAsync(T obj)
|
||||
{
|
||||
await DeleteByIdAsync(obj.Id);
|
||||
}
|
||||
|
||||
public virtual async Task DeleteByIdAsync(string id)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
$"[{Schema}].[{Table}_DeleteById]",
|
||||
new { Id = id },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
src/Core/Repositories/SqlServer/SiteRepository.cs
Normal file
47
src/Core/Repositories/SqlServer/SiteRepository.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Repositories.SqlServer.Models;
|
||||
using Dapper;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public class SiteRepository : Repository<Site, SiteTableModel>, ISiteRepository
|
||||
{
|
||||
public SiteRepository(string connectionString)
|
||||
: base(connectionString)
|
||||
{ }
|
||||
|
||||
public async Task<Site> GetByIdAsync(string id, string userId)
|
||||
{
|
||||
var site = await GetByIdAsync(id);
|
||||
if(site == null || site.UserId != userId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return site;
|
||||
}
|
||||
|
||||
public async Task<ICollection<Site>> GetManyByUserIdAsync(string userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<SiteTableModel>(
|
||||
$"[{Schema}].[{Table}_ReadByUserId]",
|
||||
new { UserId = userId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.Select(s => s.ToDomain()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Site>> GetManyByUserIdAsync(string userId, bool dirty)
|
||||
{
|
||||
return await GetManyByUserIdAsync(userId);
|
||||
}
|
||||
}
|
||||
}
|
36
src/Core/Repositories/SqlServer/UserRepository.cs
Normal file
36
src/Core/Repositories/SqlServer/UserRepository.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Repositories.SqlServer.Models;
|
||||
using Dapper;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public class UserRepository : Repository<User, UserTableModel>, IUserRepository
|
||||
{
|
||||
public UserRepository(string connectionString)
|
||||
: base(connectionString)
|
||||
{ }
|
||||
|
||||
public async Task<User> GetByEmailAsync(string email)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<UserTableModel>(
|
||||
$"[{Schema}].[{Table}_ReadByEmail]",
|
||||
new { Email = email },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
var model = results.FirstOrDefault();
|
||||
if(model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return model.ToDomain();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,8 @@
|
||||
"Sendgrid": "6.3.4",
|
||||
"Microsoft.AspNet.DataProtection.Extensions": "1.0.0-rc1-final",
|
||||
"Microsoft.Azure.DocumentDB": "1.5.2",
|
||||
"Newtonsoft.Json": "8.0.1"
|
||||
"Newtonsoft.Json": "8.0.1",
|
||||
"Dapper": "1.42.0"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
91
src/Sql/Sql.sqlproj
Normal file
91
src/Sql/Sql.sqlproj
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Name>Sql</Name>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>4.1</ProjectVersion>
|
||||
<ProjectGuid>{58554e52-fdec-4832-aff9-302b01e08dca}</ProjectGuid>
|
||||
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql120DatabaseSchemaProvider</DSP>
|
||||
<OutputType>Database</OutputType>
|
||||
<RootPath>
|
||||
</RootPath>
|
||||
<RootNamespace>Sql</RootNamespace>
|
||||
<AssemblyName>Sql</AssemblyName>
|
||||
<ModelCollation>1033,CI</ModelCollation>
|
||||
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>
|
||||
<DeployToDatabase>True</DeployToDatabase>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<TargetLanguage>CS</TargetLanguage>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<SqlServerVerification>False</SqlServerVerification>
|
||||
<IncludeCompositeObjects>True</IncludeCompositeObjects>
|
||||
<TargetDatabaseSet>True</TargetDatabaseSet>
|
||||
<DefaultCollation>SQL_Latin1_General_CP1_CI_AS</DefaultCollation>
|
||||
<DefaultFilegroup>PRIMARY</DefaultFilegroup>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
|
||||
<!-- Default to the v11.0 targets path if the targets file for the current VS version is not found -->
|
||||
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
|
||||
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
|
||||
<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties" />
|
||||
<Folder Include="dbo\" />
|
||||
<Folder Include="dbo\Tables\" />
|
||||
<Folder Include="dbo\Views\" />
|
||||
<Folder Include="dbo\Stored Procedures\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Build Include="dbo\Tables\Folder.sql" />
|
||||
<Build Include="dbo\Tables\Site.sql" />
|
||||
<Build Include="dbo\Tables\User.sql" />
|
||||
<Build Include="dbo\Views\UserView.sql" />
|
||||
<Build Include="dbo\Views\FolderView.sql" />
|
||||
<Build Include="dbo\Views\SiteView.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_ReadById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_ReadById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Site_ReadById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_ReadByEmail.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_DeleteById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_DeleteById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Site_DeleteById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_Create.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_Update.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_ReadByUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Site_ReadByUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Site_Create.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_Create.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Site_Update.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_Update.sql" />
|
||||
<Build Include="dbo\Stored Procedures\FolderAndSite_ReadByUserId.sql" />
|
||||
</ItemGroup>
|
||||
</Project>
|
18
src/Sql/dbo/Stored Procedures/FolderAndSite_ReadByUserId.sql
Normal file
18
src/Sql/dbo/Stored Procedures/FolderAndSite_ReadByUserId.sql
Normal file
@ -0,0 +1,18 @@
|
||||
CREATE PROCEDURE [dbo].[FolderAndSite_ReadByUserId]
|
||||
@UserId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[FolderView]
|
||||
WHERE
|
||||
[UserId] = @UserId
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[SiteView]
|
||||
WHERE
|
||||
[UserId] = @UserId
|
||||
END
|
25
src/Sql/dbo/Stored Procedures/Folder_Create.sql
Normal file
25
src/Sql/dbo/Stored Procedures/Folder_Create.sql
Normal file
@ -0,0 +1,25 @@
|
||||
CREATE PROCEDURE [dbo].[Folder_Create]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@Name NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
INSERT INTO [dbo].[Folder]
|
||||
(
|
||||
[Id],
|
||||
[UserId],
|
||||
[Name],
|
||||
[CreationDate],
|
||||
[RevisionDate]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@UserId,
|
||||
@Name,
|
||||
@CreationDate,
|
||||
@RevisionDate
|
||||
)
|
||||
END
|
21
src/Sql/dbo/Stored Procedures/Folder_DeleteById.sql
Normal file
21
src/Sql/dbo/Stored Procedures/Folder_DeleteById.sql
Normal file
@ -0,0 +1,21 @@
|
||||
CREATE PROCEDURE [dbo].[Folder_DeleteById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
BEGIN TRANSACTION Folder_DeleteById
|
||||
|
||||
UPDATE
|
||||
[dbo].[Site]
|
||||
SET
|
||||
[FolderId] = NULL
|
||||
WHERE
|
||||
[FolderId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Folder]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
|
||||
COMMIT TRANSACTION Folder_DeleteById
|
||||
END
|
11
src/Sql/dbo/Stored Procedures/Folder_ReadById.sql
Normal file
11
src/Sql/dbo/Stored Procedures/Folder_ReadById.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE PROCEDURE [dbo].[Folder_ReadById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[FolderView]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
11
src/Sql/dbo/Stored Procedures/Folder_ReadByUserId.sql
Normal file
11
src/Sql/dbo/Stored Procedures/Folder_ReadByUserId.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE PROCEDURE [dbo].[Folder_ReadByUserId]
|
||||
@UserId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[FolderView]
|
||||
WHERE
|
||||
[UserId] = @UserId
|
||||
END
|
17
src/Sql/dbo/Stored Procedures/Folder_Update.sql
Normal file
17
src/Sql/dbo/Stored Procedures/Folder_Update.sql
Normal file
@ -0,0 +1,17 @@
|
||||
CREATE PROCEDURE [dbo].[Folder_Update]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@Name NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
UPDATE [dbo].[Folder]
|
||||
SET
|
||||
[UserId] = @UserId,
|
||||
[Name] = @Name,
|
||||
[CreationDate] = @CreationDate,
|
||||
[RevisionDate] = @RevisionDate
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
40
src/Sql/dbo/Stored Procedures/Site_Create.sql
Normal file
40
src/Sql/dbo/Stored Procedures/Site_Create.sql
Normal file
@ -0,0 +1,40 @@
|
||||
CREATE PROCEDURE [dbo].[Site_Create]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@FolderId UNIQUEIDENTIFIER,
|
||||
@Name NVARCHAR(MAX),
|
||||
@Uri NVARCHAR(MAX),
|
||||
@Username NVARCHAR(MAX),
|
||||
@Password NVARCHAR(MAX),
|
||||
@Notes NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
INSERT INTO [dbo].[Site]
|
||||
(
|
||||
[Id],
|
||||
[UserId],
|
||||
[FolderId],
|
||||
[Name],
|
||||
[Uri],
|
||||
[Username],
|
||||
[Password],
|
||||
[Notes],
|
||||
[CreationDate],
|
||||
[RevisionDate]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@UserId,
|
||||
@FolderId,
|
||||
@Name,
|
||||
@Uri,
|
||||
@Username,
|
||||
@Password,
|
||||
@Notes,
|
||||
@CreationDate,
|
||||
@RevisionDate
|
||||
)
|
||||
END
|
10
src/Sql/dbo/Stored Procedures/Site_DeleteById.sql
Normal file
10
src/Sql/dbo/Stored Procedures/Site_DeleteById.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE PROCEDURE [dbo].[Site_DeleteById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Site]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
11
src/Sql/dbo/Stored Procedures/Site_ReadById.sql
Normal file
11
src/Sql/dbo/Stored Procedures/Site_ReadById.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE PROCEDURE [dbo].[Site_ReadById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[SiteView]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
11
src/Sql/dbo/Stored Procedures/Site_ReadByUserId.sql
Normal file
11
src/Sql/dbo/Stored Procedures/Site_ReadByUserId.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE PROCEDURE [dbo].[Site_ReadByUserId]
|
||||
@UserId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[SiteView]
|
||||
WHERE
|
||||
[UserId] = @UserId
|
||||
END
|
27
src/Sql/dbo/Stored Procedures/Site_Update.sql
Normal file
27
src/Sql/dbo/Stored Procedures/Site_Update.sql
Normal file
@ -0,0 +1,27 @@
|
||||
CREATE PROCEDURE [dbo].[Site_Update]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@FolderId UNIQUEIDENTIFIER,
|
||||
@Name NVARCHAR(MAX),
|
||||
@Uri NVARCHAR(MAX),
|
||||
@Username NVARCHAR(MAX),
|
||||
@Password NVARCHAR(MAX),
|
||||
@Notes NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
UPDATE [dbo].[Site]
|
||||
SET
|
||||
[UserId] = @UserId,
|
||||
[FolderId] = @FolderId,
|
||||
[Name] = @Name,
|
||||
[Uri] = @Uri,
|
||||
[Username] = @Username,
|
||||
[Password] = @Password,
|
||||
[Notes] = @Notes,
|
||||
[CreationDate] = @CreationDate,
|
||||
[RevisionDate] = @RevisionDate
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
43
src/Sql/dbo/Stored Procedures/User_Create.sql
Normal file
43
src/Sql/dbo/Stored Procedures/User_Create.sql
Normal file
@ -0,0 +1,43 @@
|
||||
CREATE PROCEDURE [dbo].[User_Create]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@Name NVARCHAR(50),
|
||||
@Email NVARCHAR(50),
|
||||
@MasterPassword NVARCHAR(300),
|
||||
@MasterPasswordHint NVARCHAR(50),
|
||||
@Culture NVARCHAR(10),
|
||||
@SecurityStamp NVARCHAR(50),
|
||||
@TwoFactorEnabled BIT,
|
||||
@TwoFactorProvider TINYINT,
|
||||
@AuthenticatorKey NVARCHAR(50),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
INSERT INTO [dbo].[User]
|
||||
(
|
||||
[Id],
|
||||
[Name],
|
||||
[Email],
|
||||
[MasterPassword],
|
||||
[MasterPasswordHint],
|
||||
[Culture],
|
||||
[SecurityStamp],
|
||||
[TwoFactorEnabled],
|
||||
[TwoFactorProvider],
|
||||
[AuthenticatorKey],
|
||||
[CreationDate]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@Name,
|
||||
@Email,
|
||||
@MasterPassword,
|
||||
@MasterPasswordHint,
|
||||
@Culture,
|
||||
@SecurityStamp,
|
||||
@TwoFactorEnabled,
|
||||
@TwoFactorProvider,
|
||||
@AuthenticatorKey,
|
||||
@CreationDate
|
||||
)
|
||||
END
|
26
src/Sql/dbo/Stored Procedures/User_DeleteById.sql
Normal file
26
src/Sql/dbo/Stored Procedures/User_DeleteById.sql
Normal file
@ -0,0 +1,26 @@
|
||||
CREATE PROCEDURE [dbo].[User_DeleteById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
BEGIN TRANSACTION User_DeleteById
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Site]
|
||||
WHERE
|
||||
[UserId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Folder]
|
||||
WHERE
|
||||
[UserId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[User]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
|
||||
COMMIT TRANSACTION User_DeleteById
|
||||
END
|
11
src/Sql/dbo/Stored Procedures/User_ReadByEmail.sql
Normal file
11
src/Sql/dbo/Stored Procedures/User_ReadByEmail.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE PROCEDURE [dbo].[User_ReadByEmail]
|
||||
@Email NVARCHAR(50)
|
||||
AS
|
||||
BEGIN
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[UserView]
|
||||
WHERE
|
||||
[Email] = @Email
|
||||
END
|
11
src/Sql/dbo/Stored Procedures/User_ReadById.sql
Normal file
11
src/Sql/dbo/Stored Procedures/User_ReadById.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE PROCEDURE [dbo].[User_ReadById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[UserView]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
29
src/Sql/dbo/Stored Procedures/User_Update.sql
Normal file
29
src/Sql/dbo/Stored Procedures/User_Update.sql
Normal file
@ -0,0 +1,29 @@
|
||||
CREATE PROCEDURE [dbo].[User_Update]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@Name NVARCHAR(50),
|
||||
@Email NVARCHAR(50),
|
||||
@MasterPassword NVARCHAR(300),
|
||||
@MasterPasswordHint NVARCHAR(50),
|
||||
@Culture NVARCHAR(10),
|
||||
@SecurityStamp NVARCHAR(50),
|
||||
@TwoFactorEnabled BIT,
|
||||
@TwoFactorProvider TINYINT,
|
||||
@AuthenticatorKey NVARCHAR(50),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
UPDATE [dbo].[User]
|
||||
SET
|
||||
[Name] = @Name,
|
||||
[Email] = @Email,
|
||||
[MasterPassword] = @MasterPassword,
|
||||
[MasterPasswordHint] = @MasterPasswordHint,
|
||||
[Culture] = @Culture,
|
||||
[SecurityStamp] = @SecurityStamp,
|
||||
[TwoFactorEnabled] = @TwoFactorEnabled,
|
||||
[TwoFactorProvider] = TwoFactorProvider,
|
||||
[AuthenticatorKey] = @AuthenticatorKey,
|
||||
[CreationDate] = @CreationDate
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
15
src/Sql/dbo/Tables/Folder.sql
Normal file
15
src/Sql/dbo/Tables/Folder.sql
Normal file
@ -0,0 +1,15 @@
|
||||
CREATE TABLE [dbo].[Folder] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[Name] NVARCHAR (MAX) NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||
CONSTRAINT [PK_Folder] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_Folder_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
|
||||
);
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Folder_UserId]
|
||||
ON [dbo].[Folder]([UserId] ASC);
|
||||
|
21
src/Sql/dbo/Tables/Site.sql
Normal file
21
src/Sql/dbo/Tables/Site.sql
Normal file
@ -0,0 +1,21 @@
|
||||
CREATE TABLE [dbo].[Site] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[FolderId] UNIQUEIDENTIFIER NULL,
|
||||
[Name] NVARCHAR (MAX) NOT NULL,
|
||||
[Uri] NVARCHAR (MAX) NULL,
|
||||
[Username] NVARCHAR (MAX) NULL,
|
||||
[Password] NVARCHAR (MAX) NULL,
|
||||
[Notes] NVARCHAR (MAX) NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||
CONSTRAINT [PK_Site] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_Site_Folder] FOREIGN KEY ([FolderId]) REFERENCES [dbo].[Folder] ([Id]),
|
||||
CONSTRAINT [FK_Site_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
|
||||
);
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Site_UserId]
|
||||
ON [dbo].[Site]([UserId] ASC);
|
||||
|
20
src/Sql/dbo/Tables/User.sql
Normal file
20
src/Sql/dbo/Tables/User.sql
Normal file
@ -0,0 +1,20 @@
|
||||
CREATE TABLE [dbo].[User] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[Name] NVARCHAR (50) NULL,
|
||||
[Email] NVARCHAR (50) NOT NULL,
|
||||
[MasterPassword] NVARCHAR (300) NOT NULL,
|
||||
[MasterPasswordHint] NVARCHAR (50) NULL,
|
||||
[Culture] NVARCHAR (10) NOT NULL,
|
||||
[SecurityStamp] NVARCHAR (50) NOT NULL,
|
||||
[TwoFactorEnabled] BIT NOT NULL,
|
||||
[TwoFactorProvider] TINYINT NULL,
|
||||
[AuthenticatorKey] NVARCHAR (50) NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([Id] ASC)
|
||||
);
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_User_Email]
|
||||
ON [dbo].[User]([Email] ASC);
|
||||
|
6
src/Sql/dbo/Views/FolderView.sql
Normal file
6
src/Sql/dbo/Views/FolderView.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE VIEW [dbo].[FolderView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[Folder]
|
6
src/Sql/dbo/Views/SiteView.sql
Normal file
6
src/Sql/dbo/Views/SiteView.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE VIEW [dbo].[SiteView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[Site]
|
6
src/Sql/dbo/Views/UserView.sql
Normal file
6
src/Sql/dbo/Views/UserView.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE VIEW [dbo].[UserView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[User]
|
Loading…
Reference in New Issue
Block a user