-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Identity non-core initial database migration script
- Loading branch information
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
DECLARE @CurrentMigration [nvarchar](max) | ||
|
||
IF object_id('[dbo].[__MigrationHistory]') IS NOT NULL | ||
SELECT @CurrentMigration = | ||
(SELECT TOP (1) | ||
[Project1].[MigrationId] AS [MigrationId] | ||
FROM ( SELECT | ||
[Extent1].[MigrationId] AS [MigrationId] | ||
FROM [dbo].[__MigrationHistory] AS [Extent1] | ||
WHERE [Extent1].[ContextKey] = N'IdentityFramework.Migrations.Configuration' | ||
) AS [Project1] | ||
ORDER BY [Project1].[MigrationId] DESC) | ||
|
||
IF object_id('[idFramework].[__MigrationHistory]') IS NOT NULL | ||
SELECT @CurrentMigration = | ||
(SELECT TOP (1) | ||
[Project1].[MigrationId] AS [MigrationId] | ||
FROM ( SELECT | ||
[Extent1].[MigrationId] AS [MigrationId] | ||
FROM [idFramework].[__MigrationHistory] AS [Extent1] | ||
WHERE [Extent1].[ContextKey] = N'IdentityFramework.Migrations.Configuration' | ||
) AS [Project1] | ||
ORDER BY [Project1].[MigrationId] DESC) | ||
|
||
IF @CurrentMigration IS NULL | ||
SET @CurrentMigration = '0' | ||
|
||
IF @CurrentMigration < '201903100545533_idFrameworkInitial' | ||
BEGIN | ||
IF schema_id('idFramework') IS NULL | ||
EXECUTE('CREATE SCHEMA [idFramework]') | ||
CREATE TABLE [idFramework].[AspNetRoles] ( | ||
[Id] [nvarchar](128) NOT NULL, | ||
[Name] [nvarchar](256) NOT NULL, | ||
CONSTRAINT [PK_idFramework.AspNetRoles] PRIMARY KEY ([Id]) | ||
) | ||
CREATE UNIQUE INDEX [RoleNameIndex] ON [idFramework].[AspNetRoles]([Name]) | ||
CREATE TABLE [idFramework].[AspNetUserRoles] ( | ||
[UserId] [nvarchar](128) NOT NULL, | ||
[RoleId] [nvarchar](128) NOT NULL, | ||
CONSTRAINT [PK_idFramework.AspNetUserRoles] PRIMARY KEY ([UserId], [RoleId]) | ||
) | ||
CREATE INDEX [IX_UserId] ON [idFramework].[AspNetUserRoles]([UserId]) | ||
CREATE INDEX [IX_RoleId] ON [idFramework].[AspNetUserRoles]([RoleId]) | ||
CREATE TABLE [idFramework].[AspNetUsers] ( | ||
[Id] [nvarchar](128) NOT NULL, | ||
[Email] [nvarchar](256), | ||
[EmailConfirmed] [bit] NOT NULL, | ||
[PasswordHash] [nvarchar](max), | ||
[SecurityStamp] [nvarchar](max), | ||
[PhoneNumber] [nvarchar](max), | ||
[PhoneNumberConfirmed] [bit] NOT NULL, | ||
[TwoFactorEnabled] [bit] NOT NULL, | ||
[LockoutEndDateUtc] [datetime], | ||
[LockoutEnabled] [bit] NOT NULL, | ||
[AccessFailedCount] [int] NOT NULL, | ||
[UserName] [nvarchar](256) NOT NULL, | ||
CONSTRAINT [PK_idFramework.AspNetUsers] PRIMARY KEY ([Id]) | ||
) | ||
CREATE UNIQUE INDEX [UserNameIndex] ON [idFramework].[AspNetUsers]([UserName]) | ||
CREATE TABLE [idFramework].[AspNetUserClaims] ( | ||
[Id] [int] NOT NULL IDENTITY, | ||
[UserId] [nvarchar](128) NOT NULL, | ||
[ClaimType] [nvarchar](max), | ||
[ClaimValue] [nvarchar](max), | ||
CONSTRAINT [PK_idFramework.AspNetUserClaims] PRIMARY KEY ([Id]) | ||
) | ||
CREATE INDEX [IX_UserId] ON [idFramework].[AspNetUserClaims]([UserId]) | ||
CREATE TABLE [idFramework].[AspNetUserLogins] ( | ||
[LoginProvider] [nvarchar](128) NOT NULL, | ||
[ProviderKey] [nvarchar](128) NOT NULL, | ||
[UserId] [nvarchar](128) NOT NULL, | ||
CONSTRAINT [PK_idFramework.AspNetUserLogins] PRIMARY KEY ([LoginProvider], [ProviderKey], [UserId]) | ||
) | ||
CREATE INDEX [IX_UserId] ON [idFramework].[AspNetUserLogins]([UserId]) | ||
ALTER TABLE [idFramework].[AspNetUserRoles] ADD CONSTRAINT [FK_idFramework.AspNetUserRoles_idFramework.AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [idFramework].[AspNetRoles] ([Id]) ON DELETE CASCADE | ||
ALTER TABLE [idFramework].[AspNetUserRoles] ADD CONSTRAINT [FK_idFramework.AspNetUserRoles_idFramework.AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [idFramework].[AspNetUsers] ([Id]) ON DELETE CASCADE | ||
ALTER TABLE [idFramework].[AspNetUserClaims] ADD CONSTRAINT [FK_idFramework.AspNetUserClaims_idFramework.AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [idFramework].[AspNetUsers] ([Id]) ON DELETE CASCADE | ||
ALTER TABLE [idFramework].[AspNetUserLogins] ADD CONSTRAINT [FK_idFramework.AspNetUserLogins_idFramework.AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [idFramework].[AspNetUsers] ([Id]) ON DELETE CASCADE | ||
CREATE TABLE [idFramework].[__MigrationHistory] ( | ||
[MigrationId] [nvarchar](150) NOT NULL, | ||
[ContextKey] [nvarchar](300) NOT NULL, | ||
[Model] [varbinary](max) NOT NULL, | ||
[ProductVersion] [nvarchar](32) NOT NULL, | ||
CONSTRAINT [PK_idFramework.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey]) | ||
) | ||
INSERT [idFramework].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion]) | ||
VALUES (N'201903100545533_idFrameworkInitial', N'IdentityFramework.Migrations.Configuration', 0x1F8B0800000000000400DD5CDB6EE436127D5F60FF41D05376E1B47CC90C668D7602A76DEF1A195F30ED09F236604BECB63012A548946363912FDB877C527E618B1275E345A2BAE5EE761020708BC5C362F1902C168BF3E7FFFE98FEF01C06D6134E523F2267F6D1E4D0B6307123CF27AB333BA3CB6F3FD83F7CFFF7BF4D2FBDF0D9FAB9943B61725093A467F623A5F1A9E3A4EE230E513A097D3789D26849276E143AC88B9CE3C3C37F3947470E06081BB02C6BFA2923D40F71FE037ECE22E2E2986628B8893C1CA4FC3B94CC7354EB1685388D918BCFEC6B0F435DFA7295C0B7DFA2E4EBA4A8635BE7818F409F390E96B685088928A2A0EDE9E714CF691291D53C860F2878788931C82D519062DE8BD35ADCB44387C7AC434E5DB18472B39446E140C0A3136E2147ACBE969DEDCA8260C3CBDC5EACD7B91D6B137E8A023080D8E0E92C4898F0997D5335719EC6B7984ECA8A934B61089A88079671BD838A51C79343F6DF8135CB029A25F88CE08C262838B0EEB345E0BB3FE19787E82B266727478BE5C98777EF9177F2FE3B7CF2AED953E82BC8B53EC0A7FB248A7102BAE165D57FDB72DAF51CB16255AD51A7B00A700926876DDDA0E78F98ACE8234C9BE30FB675E53F63AFFCC2C9F599F83097A0124D32F8799B05015A04B82A773ADB64FFEF68F5F8DDFB515ABD454FFE2A1F7AA17D983809CCAB4F38C84BD3473F2EA6576BBCBF70B1AB240AD9EF36BF8AD22FF3284B5CD699482BF2809215A66DEDA64E4D5E234A33A8F1695DA2EE3FB599A632BD95A2AC43EBCC84B2896DCF8652DFD76DD79871E7710C8397538B59A48B70BA2D6B22601C5892644DA323531A11E8DE5F7955BC0C911F8CB02C1AB4027EC9D24F425CF5F2C7084888C8609DEF519AC2707AFF41E96387EAF0E708AACFB19B2540A2394561FCEAADDD3F4604DF66E182CD81EDB535DAD03CFC165D219746C92561B536C6FB18B95FA38C5E12EF0251FC99BA2520FBF9E087E600A3A873EEBA384DAF80CCD89B45E0769780D7849E1C0F8663CBD4AEDD925980FC50ED97080BEA9752B4F64DD412927FA21153F9285DAA7E8C563E3153B514D5AB5A48F4AACAC586AACAC0CC34E5927A4573815E3D0BA9D1BCBE7C84C677FB72D8FDF7FB36DBBC756B41C38C735821F1BF31C1092C63DE3DA21427A41E0193756317CE423E7CACD157DF9BF2967E46413676536BCD867C11187F36E4B0FB3F1B7235E1F393EF31AFC4E030540A03BC91BCFA9CD53FE704CDB63D1D5ADDDC76E3DB590374D3E53C4D23D7CF6781220CC683186DFDC187B3FA231A456FC4A808740C88EEB32D0FBE40DF6C915477E402079862EBDC2DC2843394BAC893CD081DF2062856EEA80AC5EAE8485BB97F4A6D02D371C22A2176084A61A6FA84CAD3C227AE1FA3A0D74A424DC32D8CF5BD6A432CB9C03126ACC15E4B9834AE0E863005AA768441E9B3D0D46930AE9B881AAF5537E67D2E6C3DEE528C622B9CECF19D35BCE4FEDBAB10B3DB625B2067B7494C14D006F67641507E563125807870D937820A27260D41B94BB51582B62DB60382B64DF2E6085A1C514DC75F38AFEE1B3DDB07E5ED6FEB9DE6DA01375BF6D8336A16BE27D4A1500327323D2F16AC103F53C5E10CF4E4E7B394BBBA224518F81CD376C8A6F677957EA8D30D2292A80BB0265A0F28BF129480A4093540B93296D7A91DF72206C09671B74E58BEF60BB00D0EC8D8CDABD186A0FE025524A7D1E9A3EA59C50689E4468785068E8210E2E2D5EEB88151747159D93026BEF0106FB8D1313E181D06EAF15C35462A3B33BA954A6AF65B49E5900D71C936B292E03E69AC547666742B718EF61B49E1140C700B3632517B0B1F69B295918E6AB7A9CAA64E9137C53F4C1D4D82D5F406C5B14F568D842BFEC59A17D956B36FE7C31390C202C37153451E52A56DD5128D12B4C24229340D9A5EF9494A2F10450BC4E23C332F94C4947BAB66F92F9B6C6E9FF22096FB4029CDFE6EAFEDD2457E6BC7955D128E04D55621F36BF260BA8205EAEA164B8343014A14F1FB59146421D1BB59FADAC52D5EB37EF14546983A82FE921B25D94C7276DB0360343CF2D41875A82A5F66FDE1D243E88C5E7AA24DB3EBBC533D4A19AC6AA2E802583B1B3E9D53B3C690895EE3F011EB45789D39C653559A00FCD3408C46B68304D62833476D27A43431DB25E68842D6491352281AA06533B7A4A564B3602D3C8D45D512E62DC8D9244D74B9D41C599157D2845614AF81ADD0592C334755A49E348115C5E6D8751E8AB894EEF12EA63DCB6CB88D1587DECDF6310DC6EBAC8BE36C838DBBFD2650E3F3402C7E7B2F81F1EF7BC929EDC96F434E15118FCD38A5C1D0AF42ADBBF1F622D479A1AFC76C5D78B716FAAE0B7F3DDE30E6BE2A3FA4E39F2852B55E1D0385E3DE941FBDFA1FDD4867B142C4B64A33C226FF92521C4E98C064FE6B300B7CCC96F452E006117F89535A2479D8C78747C7C28B9DFD793DE3A4A917288EAEBA2734ED31DB42BE16794289FB8812397B6283172635A81498BE261E7E3EB3FF9BD73ACD631CECAFFCF381759D7E26FEAF19143C2419B67E97B341C7C9B83778E35129FAFB9B783C616EF2EB5FBE14550FACBB04A6D3A97528187A9DE16F3FA918A44D5175036DD67E68F176675BEBE5821255982DEB3F5458F87494470AA596DF84E8F91F4355533E44D80851F1D8602CBC514CA87B4CB00E96F62181073F69FE90605867D50F0BD6514DFBA8C027C3C1C42705E6CB50597387FB90E2D8B48D2529B7736F4AF646F999BBDE9BA4CCED8D26BA9C9D3D006ED40CECCD5C943796D93CDAD6A9485C1E0D7B97BC7FF56CE57D4950AE9DF6DDE6256F3315B9E38AE92F9581BC0739738A1CA0DDE7196F9B6BBA38F09E276B0ECB26DE33B2F16D7EF739C3DB269B2E40BCE7641B9419BC675CDBD5FEB963A6196FA13BCFF395539634F739AA28725F1E6F117287B39F575DDC00190ACFB27886A94E20D3355A9346DB702DD2DFB83E834D54409A4852FB928459F3C3FACE1D81CECE7319B3E63579A05D3AF0FDA153072E63A68326CB721799CACA3C4755F678CF7AD79578F59632935B3DE94984EFF36D3B2FF1DF5222F2284669CD22CD2DF4DBC93B1EC524634E9D0179C6F28532ECB18D7FEB11F6F9D45FD510EC5F7E24D86DEDAE95CC355946E5262F68548A08919C1B4C91075BEF7942FD25722914B34075FECE3C0FFEB1EB9205F6AEC95D46E38C429771B8085A8131E62C74B59F2753B7759EDEC5EC573A4617404D9F05F8EFC88F991F7895DE578AD891068279213C2CCCC692B2F0F0EAA542BA8D882110375FE53C3DE0300E002CBD2373F484D7D10DE8F711AF90FB52470A7520FD03D136FBF4C2472BD81A538E51D7879FC0612F7CFEFEFF514D4C4AF2540000 , N'6.2.0-61023') | ||
END | ||
|