using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace MyOffice.Migrations.Sqlite.Migrations { /// public partial class OpenIddict : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "CurrencyGlobals", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false), Symbol = table.Column(type: "TEXT", nullable: false), DefaultQuantity = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CurrencyGlobals", x => x.Id); }); migrationBuilder.CreateTable( name: "EmailTemplates", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), CreatedOn = table.Column(type: "TEXT", nullable: false), Description = table.Column(type: "TEXT", nullable: false), Subject = table.Column(type: "TEXT", nullable: false), Sender = table.Column(type: "TEXT", nullable: false), SenderName = table.Column(type: "TEXT", nullable: false), Template = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_EmailTemplates", x => x.Id); }); migrationBuilder.CreateTable( name: "ItemGlobals", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ItemGlobals", x => x.Id); }); migrationBuilder.CreateTable( name: "OpenIddictApplications", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ApplicationType = table.Column(type: "TEXT", maxLength: 50, nullable: true), ClientId = table.Column(type: "TEXT", maxLength: 100, nullable: true), ClientSecret = table.Column(type: "TEXT", nullable: true), ClientType = table.Column(type: "TEXT", maxLength: 50, nullable: true), ConcurrencyToken = table.Column(type: "TEXT", maxLength: 50, nullable: true), ConsentType = table.Column(type: "TEXT", maxLength: 50, nullable: true), DisplayName = table.Column(type: "TEXT", nullable: true), DisplayNames = table.Column(type: "TEXT", nullable: true), JsonWebKeySet = table.Column(type: "TEXT", nullable: true), Permissions = table.Column(type: "TEXT", nullable: true), PostLogoutRedirectUris = table.Column(type: "TEXT", nullable: true), Properties = table.Column(type: "TEXT", nullable: true), RedirectUris = table.Column(type: "TEXT", nullable: true), Requirements = table.Column(type: "TEXT", nullable: true), Settings = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); }); migrationBuilder.CreateTable( name: "OpenIddictScopes", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ConcurrencyToken = table.Column(type: "TEXT", maxLength: 50, nullable: true), Description = table.Column(type: "TEXT", nullable: true), Descriptions = table.Column(type: "TEXT", nullable: true), DisplayName = table.Column(type: "TEXT", nullable: true), DisplayNames = table.Column(type: "TEXT", nullable: true), Name = table.Column(type: "TEXT", maxLength: 200, nullable: true), Properties = table.Column(type: "TEXT", nullable: true), Resources = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), UserName = table.Column(type: "TEXT", nullable: false, collation: "NOCASE"), Email = table.Column(type: "TEXT", nullable: false, collation: "NOCASE"), PasswordHash = table.Column(type: "TEXT", nullable: false), FirstName = table.Column(type: "TEXT", nullable: true), LastName = table.Column(type: "TEXT", nullable: true), FullName = table.Column(type: "TEXT", nullable: true), Phone = table.Column(type: "TEXT", nullable: true), IsEmailConfirmed = table.Column(type: "INTEGER", nullable: false), CurrencyId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); table.ForeignKey( name: "FK_Users_CurrencyGlobals_CurrencyId", column: x => x.CurrencyId, principalTable: "CurrencyGlobals", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "OpenIddictAuthorizations", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ApplicationId = table.Column(type: "TEXT", nullable: true), ConcurrencyToken = table.Column(type: "TEXT", maxLength: 50, nullable: true), CreationDate = table.Column(type: "TEXT", nullable: true), Properties = table.Column(type: "TEXT", nullable: true), Scopes = table.Column(type: "TEXT", nullable: true), Status = table.Column(type: "TEXT", maxLength: 50, nullable: true), Subject = table.Column(type: "TEXT", maxLength: 400, nullable: true), Type = table.Column(type: "TEXT", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); table.ForeignKey( name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "AccountCategories", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AccountCategories", x => x.Id); table.ForeignKey( name: "FK_AccountCategories_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), CurrencyGlobalId = table.Column(type: "TEXT", nullable: false), OwnerId = table.Column(type: "TEXT", nullable: true), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Accounts", x => x.Id); table.ForeignKey( name: "FK_Accounts_CurrencyGlobals_CurrencyGlobalId", column: x => x.CurrencyGlobalId, principalTable: "CurrencyGlobals", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Accounts_Users_OwnerId", column: x => x.OwnerId, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "ItemCategories", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false), IsInternal = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ItemCategories", x => x.Id); table.ForeignKey( name: "FK_ItemCategories_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserClaims", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), CreatedOn = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), ExternalId = table.Column(type: "TEXT", nullable: false), Email = table.Column(type: "TEXT", nullable: false, collation: "NOCASE"), Provider = table.Column(type: "TEXT", nullable: false, collation: "NOCASE") }, constraints: table => { table.PrimaryKey("PK_UserClaims", x => x.Id); table.ForeignKey( name: "FK_UserClaims_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Verifications", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), UserId = table.Column(type: "TEXT", nullable: false), Code = table.Column(type: "TEXT", nullable: false), DestinationType = table.Column(type: "TEXT", nullable: false), Destination = table.Column(type: "TEXT", nullable: false), CreatedOn = table.Column(type: "TEXT", nullable: false), ExpiresOn = table.Column(type: "TEXT", nullable: false), VerifiedOn = table.Column(type: "TEXT", nullable: true), Template = table.Column(type: "TEXT", nullable: false), Metadata = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Verifications", x => x.Id); table.ForeignKey( name: "FK_Verifications_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "OpenIddictTokens", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ApplicationId = table.Column(type: "TEXT", nullable: true), AuthorizationId = table.Column(type: "TEXT", nullable: true), ConcurrencyToken = table.Column(type: "TEXT", maxLength: 50, nullable: true), CreationDate = table.Column(type: "TEXT", nullable: true), ExpirationDate = table.Column(type: "TEXT", nullable: true), Payload = table.Column(type: "TEXT", nullable: true), Properties = table.Column(type: "TEXT", nullable: true), RedemptionDate = table.Column(type: "TEXT", nullable: true), ReferenceId = table.Column(type: "TEXT", maxLength: 100, nullable: true), Status = table.Column(type: "TEXT", maxLength: 50, nullable: true), Subject = table.Column(type: "TEXT", maxLength: 400, nullable: true), Type = table.Column(type: "TEXT", maxLength: 150, nullable: true) }, constraints: table => { table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id"); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", column: x => x.AuthorizationId, principalTable: "OpenIddictAuthorizations", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "AccountAccesses", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), AccountId = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), OwnerId = table.Column(type: "TEXT", nullable: false), IsAllowRead = table.Column(type: "INTEGER", nullable: false), IsAllowWrite = table.Column(type: "INTEGER", nullable: false), IsAllowManage = table.Column(type: "INTEGER", nullable: false), Type = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AccountAccesses", x => x.Id); table.ForeignKey( name: "FK_AccountAccesses_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AccountAccesses_Users_OwnerId", column: x => x.OwnerId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AccountAccesses_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AccountAccessInvites", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), AccountId = table.Column(type: "TEXT", nullable: false), CreatedOn = table.Column(type: "TEXT", nullable: false), AcceptedOn = table.Column(type: "TEXT", nullable: true), RejectedOn = table.Column(type: "TEXT", nullable: true), Email = table.Column(type: "TEXT", nullable: false), IsAllowWrite = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AccountAccessInvites", x => x.Id); table.ForeignKey( name: "FK_AccountAccessInvites_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AccountAccessInvites_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AccountAccountCategories", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), AccountId = table.Column(type: "TEXT", nullable: false), CategoryId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AccountAccountCategories", x => x.Id); table.ForeignKey( name: "FK_AccountAccountCategories_AccountCategories_CategoryId", column: x => x.CategoryId, principalTable: "AccountCategories", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AccountAccountCategories_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Items", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), CategoryId = table.Column(type: "TEXT", nullable: false), ItemGlobalId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Items", x => x.Id); table.ForeignKey( name: "FK_Items_ItemCategories_CategoryId", column: x => x.CategoryId, principalTable: "ItemCategories", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Items_ItemGlobals_ItemGlobalId", column: x => x.ItemGlobalId, principalTable: "ItemGlobals", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Motions", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), CreatedOn = table.Column(type: "TEXT", nullable: false), DateTime = table.Column(type: "TEXT", nullable: false), AccountId = table.Column(type: "TEXT", nullable: false), ItemId = table.Column(type: "INTEGER", nullable: false), Description = table.Column(type: "TEXT", nullable: true), AmountPlus = table.Column(type: "TEXT", precision: 18, scale: 6, nullable: false), AmountMinus = table.Column(type: "TEXT", precision: 18, scale: 6, nullable: false), DeletedOn = table.Column(type: "TEXT", nullable: true), UserId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Motions", x => x.Id); table.ForeignKey( name: "FK_Motions_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Motions_Items_ItemId", column: x => x.ItemId, principalTable: "Items", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Motions_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Currencies", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), CurrencyGlobalId = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false), ShortName = table.Column(type: "TEXT", nullable: false), CurrentRateId = table.Column(type: "INTEGER", nullable: true), IsPrimary = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Currencies", x => x.Id); table.ForeignKey( name: "FK_Currencies_CurrencyGlobals_CurrencyGlobalId", column: x => x.CurrencyGlobalId, principalTable: "CurrencyGlobals", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Currencies_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "CurrencyRates", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), CurrencyId = table.Column(type: "TEXT", nullable: false), DateTime = table.Column(type: "TEXT", nullable: false), Quantity = table.Column(type: "INTEGER", nullable: false), Rate = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CurrencyRates", x => x.Id); table.ForeignKey( name: "FK_CurrencyRates_Currencies_CurrencyId", column: x => x.CurrencyId, principalTable: "Currencies", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AccountAccesses_AccountId_OwnerId", table: "AccountAccesses", columns: new[] { "AccountId", "OwnerId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_AccountAccesses_AccountId_UserId", table: "AccountAccesses", columns: new[] { "AccountId", "UserId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_AccountAccesses_OwnerId", table: "AccountAccesses", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_AccountAccesses_UserId", table: "AccountAccesses", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AccountAccessInvites_AccountId", table: "AccountAccessInvites", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_AccountAccessInvites_UserId", table: "AccountAccessInvites", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AccountAccountCategories_AccountId_CategoryId", table: "AccountAccountCategories", columns: new[] { "AccountId", "CategoryId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_AccountAccountCategories_CategoryId", table: "AccountAccountCategories", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_AccountCategories_UserId", table: "AccountCategories", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Accounts_CurrencyGlobalId", table: "Accounts", column: "CurrencyGlobalId"); migrationBuilder.CreateIndex( name: "IX_Accounts_OwnerId", table: "Accounts", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_Currencies_CurrencyGlobalId", table: "Currencies", column: "CurrencyGlobalId"); migrationBuilder.CreateIndex( name: "IX_Currencies_CurrentRateId", table: "Currencies", column: "CurrentRateId"); migrationBuilder.CreateIndex( name: "IX_Currencies_UserId", table: "Currencies", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_CurrencyRates_CurrencyId", table: "CurrencyRates", column: "CurrencyId"); migrationBuilder.CreateIndex( name: "IX_ItemCategories_UserId", table: "ItemCategories", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Items_CategoryId", table: "Items", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_Items_ItemGlobalId", table: "Items", column: "ItemGlobalId"); migrationBuilder.CreateIndex( name: "IX_Motions_AccountId", table: "Motions", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_Motions_ItemId", table: "Motions", column: "ItemId"); migrationBuilder.CreateIndex( name: "IX_Motions_UserId", table: "Motions", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_OpenIddictApplications_ClientId", table: "OpenIddictApplications", column: "ClientId", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", table: "OpenIddictAuthorizations", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); migrationBuilder.CreateIndex( name: "IX_OpenIddictScopes_Name", table: "OpenIddictScopes", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", table: "OpenIddictTokens", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_AuthorizationId", table: "OpenIddictTokens", column: "AuthorizationId"); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ReferenceId", table: "OpenIddictTokens", column: "ReferenceId", unique: true); migrationBuilder.CreateIndex( name: "IX_UserClaims_UserId", table: "UserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Users_CurrencyId", table: "Users", column: "CurrencyId"); migrationBuilder.CreateIndex( name: "IX_Verifications_UserId", table: "Verifications", column: "UserId"); migrationBuilder.AddForeignKey( name: "FK_Currencies_CurrencyRates_CurrentRateId", table: "Currencies", column: "CurrentRateId", principalTable: "CurrencyRates", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Currencies_Users_UserId", table: "Currencies"); migrationBuilder.DropForeignKey( name: "FK_Currencies_CurrencyGlobals_CurrencyGlobalId", table: "Currencies"); migrationBuilder.DropForeignKey( name: "FK_Currencies_CurrencyRates_CurrentRateId", table: "Currencies"); migrationBuilder.DropTable( name: "AccountAccesses"); migrationBuilder.DropTable( name: "AccountAccessInvites"); migrationBuilder.DropTable( name: "AccountAccountCategories"); migrationBuilder.DropTable( name: "EmailTemplates"); migrationBuilder.DropTable( name: "Motions"); migrationBuilder.DropTable( name: "OpenIddictScopes"); migrationBuilder.DropTable( name: "OpenIddictTokens"); migrationBuilder.DropTable( name: "UserClaims"); migrationBuilder.DropTable( name: "Verifications"); migrationBuilder.DropTable( name: "AccountCategories"); migrationBuilder.DropTable( name: "Accounts"); migrationBuilder.DropTable( name: "Items"); migrationBuilder.DropTable( name: "OpenIddictAuthorizations"); migrationBuilder.DropTable( name: "ItemCategories"); migrationBuilder.DropTable( name: "ItemGlobals"); migrationBuilder.DropTable( name: "OpenIddictApplications"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "CurrencyGlobals"); migrationBuilder.DropTable( name: "CurrencyRates"); migrationBuilder.DropTable( name: "Currencies"); } } }