diff --git a/db/Postgres/FreshCreateOnLatestVersion.sql b/db/Postgres/FreshCreateOnLatestVersion.sql new file mode 100644 index 00000000..2e4d06fa --- /dev/null +++ b/db/Postgres/FreshCreateOnLatestVersion.sql @@ -0,0 +1,786 @@ +CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( + "MigrationId" character varying(150) NOT NULL, + "ProductVersion" character varying(32) NOT NULL, + CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") +); + +START TRANSACTION; + +CREATE TABLE "AuditLogs" ( + "Id" uuid NOT NULL, + "EntityId" uuid, + "Category" text NOT NULL, + "Request" text NOT NULL, + "UserEmail" text NOT NULL, + "IpAddress" text NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + CONSTRAINT "PK_AuditLogs" PRIMARY KEY ("Id") +); + +CREATE TABLE "BackgroundTasks" ( + "Id" uuid NOT NULL, + "Name" text NOT NULL, + "Args" text, + "ErrorMessage" text, + "Status" text NOT NULL, + "StatusInfo" text, + "PercentComplete" integer NOT NULL, + "NumberOfRetries" integer NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CompletionTime" timestamp with time zone, + "TaskStep" integer NOT NULL, + CONSTRAINT "PK_BackgroundTasks" PRIMARY KEY ("Id") +); + +CREATE TABLE "DataProtectionKeys" ( + "Id" integer GENERATED BY DEFAULT AS IDENTITY, + "FriendlyName" text, + "Xml" text, + CONSTRAINT "PK_DataProtectionKeys" PRIMARY KEY ("Id") +); + +CREATE TABLE "JwtLogins" ( + "Id" uuid NOT NULL, + "Jti" text, + "CreationTime" timestamp with time zone NOT NULL, + CONSTRAINT "PK_JwtLogins" PRIMARY KEY ("Id") +); + +CREATE TABLE "OrganizationSettings" ( + "Id" uuid NOT NULL, + "OrganizationName" text, + "WebsiteUrl" text, + "TimeZone" text, + "DateFormat" text, + "SmtpOverrideSystem" boolean NOT NULL, + "SmtpHost" text, + "SmtpPort" integer, + "SmtpUsername" text, + "SmtpPassword" text, + "SmtpDefaultFromAddress" text, + "SmtpDefaultFromName" text, + "HomePageId" uuid, + "HomePageType" text NOT NULL, + "ActiveThemeId" uuid NOT NULL, + CONSTRAINT "PK_OrganizationSettings" PRIMARY KEY ("Id") +); + +CREATE TABLE "Routes" ( + "Id" uuid NOT NULL, + "Path" text NOT NULL, + "ContentItemId" uuid NOT NULL, + "ViewId" uuid NOT NULL, + CONSTRAINT "PK_Routes" PRIMARY KEY ("Id") +); + +CREATE TABLE "ApiKeys" ( + "Id" uuid NOT NULL, + "ApiKeyHash" bytea NOT NULL, + "UserId" uuid NOT NULL, + "CreatorUserId" uuid, + "CreationTime" timestamp with time zone NOT NULL, + CONSTRAINT "PK_ApiKeys" PRIMARY KEY ("Id") +); + +CREATE TABLE "AuthenticationSchemes" ( + "Id" uuid NOT NULL, + "IsBuiltInAuth" boolean NOT NULL, + "IsEnabledForUsers" boolean NOT NULL, + "IsEnabledForAdmins" boolean NOT NULL, + "AuthenticationSchemeType" text, + "Label" text, + "DeveloperName" text, + "MagicLinkExpiresInSeconds" integer NOT NULL, + "SamlCertificate" text, + "SamlIdpEntityId" text, + "JwtSecretKey" text, + "JwtUseHighSecurity" boolean NOT NULL, + "SignInUrl" text, + "LoginButtonText" text, + "SignOutUrl" text, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_AuthenticationSchemes" PRIMARY KEY ("Id") +); + +CREATE TABLE "Users" ( + "Id" uuid NOT NULL, + "IsAdmin" boolean NOT NULL, + "IsActive" boolean NOT NULL, + "LastLoggedInTime" timestamp with time zone, + "Salt" bytea NOT NULL, + "PasswordHash" bytea NOT NULL, + "SsoId" text, + "AuthenticationSchemeId" uuid, + "FirstName" text NOT NULL, + "LastName" text NOT NULL, + "EmailAddress" text NOT NULL, + "IsEmailAddressConfirmed" boolean NOT NULL, + "_RecentlyAccessedViews" text, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_Users" PRIMARY KEY ("Id"), + CONSTRAINT "FK_Users_AuthenticationSchemes_AuthenticationSchemeId" FOREIGN KEY ("AuthenticationSchemeId") REFERENCES "AuthenticationSchemes" ("Id"), + CONSTRAINT "FK_Users_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_Users_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "ContentTypes" ( + "Id" uuid NOT NULL, + "IsActive" boolean NOT NULL, + "LabelPlural" text, + "LabelSingular" text, + "DeveloperName" text, + "Description" text, + "DefaultRouteTemplate" text, + "PrimaryFieldId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + "DeleterUserId" uuid, + "DeletionTime" timestamp with time zone, + "IsDeleted" boolean NOT NULL, + CONSTRAINT "PK_ContentTypes" PRIMARY KEY ("Id"), + CONSTRAINT "FK_ContentTypes_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_ContentTypes_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "EmailTemplates" ( + "Id" uuid NOT NULL, + "Subject" text, + "DeveloperName" text, + "Cc" text, + "Bcc" text, + "Content" text, + "IsBuiltInTemplate" boolean NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_EmailTemplates" PRIMARY KEY ("Id"), + CONSTRAINT "FK_EmailTemplates_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_EmailTemplates_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "MediaItems" ( + "Id" uuid NOT NULL, + "Length" bigint NOT NULL, + "FileName" text NOT NULL, + "ContentType" text NOT NULL, + "FileStorageProvider" text NOT NULL, + "ObjectKey" text NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_MediaItems" PRIMARY KEY ("Id"), + CONSTRAINT "FK_MediaItems_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_MediaItems_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "NavigationMenus" ( + "Id" uuid NOT NULL, + "Label" text NOT NULL, + "DeveloperName" text NOT NULL, + "IsMainMenu" boolean NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_NavigationMenus" PRIMARY KEY ("Id"), + CONSTRAINT "FK_NavigationMenus_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_NavigationMenus_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "OneTimePasswords" ( + "Id" bytea NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "ExpiresAt" timestamp with time zone NOT NULL, + "IsUsed" boolean NOT NULL, + "UserId" uuid NOT NULL, + CONSTRAINT "PK_OneTimePasswords" PRIMARY KEY ("Id"), + CONSTRAINT "FK_OneTimePasswords_Users_UserId" FOREIGN KEY ("UserId") REFERENCES "Users" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "RaythaFunctions" ( + "Id" uuid NOT NULL, + "Name" text NOT NULL, + "DeveloperName" text NOT NULL, + "TriggerType" text NOT NULL, + "Code" text NOT NULL, + "IsActive" boolean NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_RaythaFunctions" PRIMARY KEY ("Id"), + CONSTRAINT "FK_RaythaFunctions_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_RaythaFunctions_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "Roles" ( + "Id" uuid NOT NULL, + "Label" text NOT NULL, + "DeveloperName" text NOT NULL, + "SystemPermissions" integer NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_Roles" PRIMARY KEY ("Id"), + CONSTRAINT "FK_Roles_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_Roles_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "Themes" ( + "Id" uuid NOT NULL, + "Title" text NOT NULL, + "DeveloperName" text NOT NULL, + "Description" text NOT NULL, + "IsExportable" boolean NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_Themes" PRIMARY KEY ("Id"), + CONSTRAINT "FK_Themes_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_Themes_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "UserGroups" ( + "Id" uuid NOT NULL, + "Label" text NOT NULL, + "DeveloperName" text NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_UserGroups" PRIMARY KEY ("Id"), + CONSTRAINT "FK_UserGroups_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_UserGroups_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "VerificationCodes" ( + "Id" uuid NOT NULL, + "Code" uuid NOT NULL, + "ExpiresAt" timestamp with time zone NOT NULL, + "Completed" boolean NOT NULL, + "EmailAddress" text, + "VerificationCodeType" text NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_VerificationCodes" PRIMARY KEY ("Id"), + CONSTRAINT "FK_VerificationCodes_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_VerificationCodes_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "ContentItems" ( + "Id" uuid NOT NULL, + "IsPublished" boolean NOT NULL, + "IsDraft" boolean NOT NULL, + "_DraftContent" text, + "_PublishedContent" jsonb, + "ContentTypeId" uuid NOT NULL, + "RouteId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_ContentItems" PRIMARY KEY ("Id"), + CONSTRAINT "FK_ContentItems_ContentTypes_ContentTypeId" FOREIGN KEY ("ContentTypeId") REFERENCES "ContentTypes" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_ContentItems_Routes_RouteId" FOREIGN KEY ("RouteId") REFERENCES "Routes" ("Id"), + CONSTRAINT "FK_ContentItems_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_ContentItems_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "ContentTypeFields" ( + "Id" uuid NOT NULL, + "Label" text, + "DeveloperName" text, + "Description" text, + "FieldOrder" integer NOT NULL, + "IsRequired" boolean NOT NULL, + "RelatedContentTypeId" uuid, + "ContentTypeId" uuid NOT NULL, + "FieldType" text NOT NULL, + "_Choices" text NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + "DeleterUserId" uuid, + "DeletionTime" timestamp with time zone, + "IsDeleted" boolean NOT NULL, + CONSTRAINT "PK_ContentTypeFields" PRIMARY KEY ("Id"), + CONSTRAINT "FK_ContentTypeFields_ContentTypes_ContentTypeId" FOREIGN KEY ("ContentTypeId") REFERENCES "ContentTypes" ("Id"), + CONSTRAINT "FK_ContentTypeFields_ContentTypes_RelatedContentTypeId" FOREIGN KEY ("RelatedContentTypeId") REFERENCES "ContentTypes" ("Id"), + CONSTRAINT "FK_ContentTypeFields_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_ContentTypeFields_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "DeletedContentItems" ( + "Id" uuid NOT NULL, + "_PublishedContent" text, + "PrimaryField" text, + "ContentTypeId" uuid NOT NULL, + "OriginalContentItemId" uuid NOT NULL, + "RoutePath" text NOT NULL, + "WebTemplateIdsJson" text NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_DeletedContentItems" PRIMARY KEY ("Id"), + CONSTRAINT "FK_DeletedContentItems_ContentTypes_ContentTypeId" FOREIGN KEY ("ContentTypeId") REFERENCES "ContentTypes" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_DeletedContentItems_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_DeletedContentItems_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "Views" ( + "Id" uuid NOT NULL, + "Label" text, + "DeveloperName" text, + "Description" text, + "ContentTypeId" uuid NOT NULL, + "RouteId" uuid NOT NULL, + "IsPublished" boolean NOT NULL, + "DefaultNumberOfItemsPerPage" integer NOT NULL, + "MaxNumberOfItemsPerPage" integer NOT NULL, + "IgnoreClientFilterAndSortQueryParams" boolean NOT NULL, + "_Columns" text, + "_Filter" text, + "_Sort" text, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_Views" PRIMARY KEY ("Id"), + CONSTRAINT "FK_Views_ContentTypes_ContentTypeId" FOREIGN KEY ("ContentTypeId") REFERENCES "ContentTypes" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_Views_Routes_RouteId" FOREIGN KEY ("RouteId") REFERENCES "Routes" ("Id"), + CONSTRAINT "FK_Views_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_Views_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "EmailTemplateRevisions" ( + "Id" uuid NOT NULL, + "Subject" text, + "Content" text, + "Cc" text, + "Bcc" text, + "EmailTemplateId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_EmailTemplateRevisions" PRIMARY KEY ("Id"), + CONSTRAINT "FK_EmailTemplateRevisions_EmailTemplates_EmailTemplateId" FOREIGN KEY ("EmailTemplateId") REFERENCES "EmailTemplates" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_EmailTemplateRevisions_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_EmailTemplateRevisions_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "NavigationMenuItems" ( + "Id" uuid NOT NULL, + "Label" text NOT NULL, + "Url" text NOT NULL, + "IsDisabled" boolean NOT NULL, + "OpenInNewTab" boolean NOT NULL, + "CssClassName" text, + "Ordinal" integer NOT NULL, + "ParentNavigationMenuItemId" uuid, + "NavigationMenuId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_NavigationMenuItems" PRIMARY KEY ("Id"), + CONSTRAINT "FK_NavigationMenuItems_NavigationMenuItems_ParentNavigationMen~" FOREIGN KEY ("ParentNavigationMenuItemId") REFERENCES "NavigationMenuItems" ("Id"), + CONSTRAINT "FK_NavigationMenuItems_NavigationMenus_NavigationMenuId" FOREIGN KEY ("NavigationMenuId") REFERENCES "NavigationMenus" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_NavigationMenuItems_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_NavigationMenuItems_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "NavigationMenuRevisions" ( + "Id" uuid NOT NULL, + "NavigationMenuItemsJson" text NOT NULL, + "NavigationMenuId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_NavigationMenuRevisions" PRIMARY KEY ("Id"), + CONSTRAINT "FK_NavigationMenuRevisions_NavigationMenus_NavigationMenuId" FOREIGN KEY ("NavigationMenuId") REFERENCES "NavigationMenus" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_NavigationMenuRevisions_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_NavigationMenuRevisions_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "RaythaFunctionRevisions" ( + "Id" uuid NOT NULL, + "Code" text NOT NULL, + "RaythaFunctionId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_RaythaFunctionRevisions" PRIMARY KEY ("Id"), + CONSTRAINT "FK_RaythaFunctionRevisions_RaythaFunctions_RaythaFunctionId" FOREIGN KEY ("RaythaFunctionId") REFERENCES "RaythaFunctions" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_RaythaFunctionRevisions_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_RaythaFunctionRevisions_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "ContentTypeRolePermission" ( + "Id" uuid NOT NULL, + "ContentTypeId" uuid NOT NULL, + "ContentTypePermissions" integer NOT NULL, + "RoleId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_ContentTypeRolePermission" PRIMARY KEY ("Id"), + CONSTRAINT "FK_ContentTypeRolePermission_ContentTypes_ContentTypeId" FOREIGN KEY ("ContentTypeId") REFERENCES "ContentTypes" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_ContentTypeRolePermission_Roles_RoleId" FOREIGN KEY ("RoleId") REFERENCES "Roles" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_ContentTypeRolePermission_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_ContentTypeRolePermission_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "RoleUser" ( + "RolesId" uuid NOT NULL, + "UsersId" uuid NOT NULL, + CONSTRAINT "PK_RoleUser" PRIMARY KEY ("RolesId", "UsersId"), + CONSTRAINT "FK_RoleUser_Roles_RolesId" FOREIGN KEY ("RolesId") REFERENCES "Roles" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_RoleUser_Users_UsersId" FOREIGN KEY ("UsersId") REFERENCES "Users" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "ThemeAccessToMediaItems" ( + "Id" uuid NOT NULL, + "ThemeId" uuid NOT NULL, + "MediaItemId" uuid NOT NULL, + CONSTRAINT "PK_ThemeAccessToMediaItems" PRIMARY KEY ("Id"), + CONSTRAINT "FK_ThemeAccessToMediaItems_MediaItems_MediaItemId" FOREIGN KEY ("MediaItemId") REFERENCES "MediaItems" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_ThemeAccessToMediaItems_Themes_ThemeId" FOREIGN KEY ("ThemeId") REFERENCES "Themes" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "WebTemplates" ( + "Id" uuid NOT NULL, + "ThemeId" uuid NOT NULL, + "IsBaseLayout" boolean NOT NULL, + "Label" text, + "DeveloperName" text, + "Content" text, + "IsBuiltInTemplate" boolean NOT NULL, + "ParentTemplateId" uuid, + "AllowAccessForNewContentTypes" boolean NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_WebTemplates" PRIMARY KEY ("Id"), + CONSTRAINT "FK_WebTemplates_Themes_ThemeId" FOREIGN KEY ("ThemeId") REFERENCES "Themes" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_WebTemplates_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_WebTemplates_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_WebTemplates_WebTemplates_ParentTemplateId" FOREIGN KEY ("ParentTemplateId") REFERENCES "WebTemplates" ("Id") +); + +CREATE TABLE "UserUserGroup" ( + "UserGroupsId" uuid NOT NULL, + "UsersId" uuid NOT NULL, + CONSTRAINT "PK_UserUserGroup" PRIMARY KEY ("UserGroupsId", "UsersId"), + CONSTRAINT "FK_UserUserGroup_UserGroups_UserGroupsId" FOREIGN KEY ("UserGroupsId") REFERENCES "UserGroups" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_UserUserGroup_Users_UsersId" FOREIGN KEY ("UsersId") REFERENCES "Users" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "ContentItemRevisions" ( + "Id" uuid NOT NULL, + "_PublishedContent" text, + "ContentItemId" uuid NOT NULL, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_ContentItemRevisions" PRIMARY KEY ("Id"), + CONSTRAINT "FK_ContentItemRevisions_ContentItems_ContentItemId" FOREIGN KEY ("ContentItemId") REFERENCES "ContentItems" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_ContentItemRevisions_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_ContentItemRevisions_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id") +); + +CREATE TABLE "UserView" ( + "FavoriteViewsId" uuid NOT NULL, + "UserFavoritesId" uuid NOT NULL, + CONSTRAINT "PK_UserView" PRIMARY KEY ("FavoriteViewsId", "UserFavoritesId"), + CONSTRAINT "FK_UserView_Users_UserFavoritesId" FOREIGN KEY ("UserFavoritesId") REFERENCES "Users" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_UserView_Views_FavoriteViewsId" FOREIGN KEY ("FavoriteViewsId") REFERENCES "Views" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "WebTemplateAccessToModelDefinitions" ( + "Id" uuid NOT NULL, + "WebTemplateId" uuid NOT NULL, + "ContentTypeId" uuid NOT NULL, + CONSTRAINT "PK_WebTemplateAccessToModelDefinitions" PRIMARY KEY ("Id"), + CONSTRAINT "FK_WebTemplateAccessToModelDefinitions_ContentTypes_ContentTyp~" FOREIGN KEY ("ContentTypeId") REFERENCES "ContentTypes" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_WebTemplateAccessToModelDefinitions_WebTemplates_WebTemplat~" FOREIGN KEY ("WebTemplateId") REFERENCES "WebTemplates" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "WebTemplateContentItemRelations" ( + "Id" uuid NOT NULL, + "WebTemplateId" uuid NOT NULL, + "ContentItemId" uuid NOT NULL, + CONSTRAINT "PK_WebTemplateContentItemRelations" PRIMARY KEY ("Id"), + CONSTRAINT "FK_WebTemplateContentItemRelations_ContentItems_ContentItemId" FOREIGN KEY ("ContentItemId") REFERENCES "ContentItems" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_WebTemplateContentItemRelations_WebTemplates_WebTemplateId" FOREIGN KEY ("WebTemplateId") REFERENCES "WebTemplates" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "WebTemplateRevisions" ( + "Id" uuid NOT NULL, + "Label" text, + "Content" text, + "WebTemplateId" uuid NOT NULL, + "AllowAccessForNewContentTypes" boolean NOT NULL, + "EmailTemplateId" uuid, + "CreationTime" timestamp with time zone NOT NULL, + "LastModificationTime" timestamp with time zone, + "CreatorUserId" uuid, + "LastModifierUserId" uuid, + CONSTRAINT "PK_WebTemplateRevisions" PRIMARY KEY ("Id"), + CONSTRAINT "FK_WebTemplateRevisions_EmailTemplates_EmailTemplateId" FOREIGN KEY ("EmailTemplateId") REFERENCES "EmailTemplates" ("Id"), + CONSTRAINT "FK_WebTemplateRevisions_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_WebTemplateRevisions_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id"), + CONSTRAINT "FK_WebTemplateRevisions_WebTemplates_WebTemplateId" FOREIGN KEY ("WebTemplateId") REFERENCES "WebTemplates" ("Id") ON DELETE CASCADE +); + +CREATE TABLE "WebTemplateViewRelations" ( + "Id" uuid NOT NULL, + "WebTemplateId" uuid NOT NULL, + "ViewId" uuid NOT NULL, + CONSTRAINT "PK_WebTemplateViewRelations" PRIMARY KEY ("Id"), + CONSTRAINT "FK_WebTemplateViewRelations_Views_ViewId" FOREIGN KEY ("ViewId") REFERENCES "Views" ("Id") ON DELETE CASCADE, + CONSTRAINT "FK_WebTemplateViewRelations_WebTemplates_WebTemplateId" FOREIGN KEY ("WebTemplateId") REFERENCES "WebTemplates" ("Id") ON DELETE CASCADE +); + +CREATE UNIQUE INDEX "IX_ApiKeys_ApiKeyHash" ON "ApiKeys" ("ApiKeyHash"); + +CREATE INDEX "IX_ApiKeys_CreatorUserId" ON "ApiKeys" ("CreatorUserId"); + +CREATE INDEX "IX_ApiKeys_UserId" ON "ApiKeys" ("UserId"); + +CREATE INDEX "IX_AuditLogs_Category" ON "AuditLogs" ("Category"); + +CREATE INDEX "IX_AuditLogs_CreationTime" ON "AuditLogs" ("CreationTime"); + +CREATE INDEX "IX_AuditLogs_EntityId" ON "AuditLogs" ("EntityId"); + +CREATE INDEX "IX_AuthenticationSchemes_CreatorUserId" ON "AuthenticationSchemes" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_AuthenticationSchemes_DeveloperName" ON "AuthenticationSchemes" ("DeveloperName"); + +CREATE INDEX "IX_AuthenticationSchemes_LastModifierUserId" ON "AuthenticationSchemes" ("LastModifierUserId"); + +CREATE INDEX "IX_ContentItemRevisions_ContentItemId" ON "ContentItemRevisions" ("ContentItemId"); + +CREATE INDEX "IX_ContentItemRevisions_CreatorUserId" ON "ContentItemRevisions" ("CreatorUserId"); + +CREATE INDEX "IX_ContentItemRevisions_LastModifierUserId" ON "ContentItemRevisions" ("LastModifierUserId"); + +CREATE INDEX "IX_ContentItems_ContentTypeId" ON "ContentItems" ("ContentTypeId"); + +CREATE INDEX "IX_ContentItems_CreatorUserId" ON "ContentItems" ("CreatorUserId"); + +CREATE INDEX "IX_ContentItems_LastModifierUserId" ON "ContentItems" ("LastModifierUserId"); + +CREATE UNIQUE INDEX "IX_ContentItems_RouteId" ON "ContentItems" ("RouteId"); + +CREATE INDEX "IX_ContentTypeFields_ContentTypeId" ON "ContentTypeFields" ("ContentTypeId"); + +CREATE INDEX "IX_ContentTypeFields_CreatorUserId" ON "ContentTypeFields" ("CreatorUserId"); + +CREATE INDEX "IX_ContentTypeFields_LastModifierUserId" ON "ContentTypeFields" ("LastModifierUserId"); + +CREATE INDEX "IX_ContentTypeFields_RelatedContentTypeId" ON "ContentTypeFields" ("RelatedContentTypeId"); + +CREATE INDEX "IX_ContentTypeRolePermission_ContentTypeId" ON "ContentTypeRolePermission" ("ContentTypeId"); + +CREATE INDEX "IX_ContentTypeRolePermission_CreatorUserId" ON "ContentTypeRolePermission" ("CreatorUserId"); + +CREATE INDEX "IX_ContentTypeRolePermission_LastModifierUserId" ON "ContentTypeRolePermission" ("LastModifierUserId"); + +CREATE INDEX "IX_ContentTypeRolePermission_RoleId" ON "ContentTypeRolePermission" ("RoleId"); + +CREATE INDEX "IX_ContentTypes_CreatorUserId" ON "ContentTypes" ("CreatorUserId"); + +CREATE INDEX "IX_ContentTypes_LastModifierUserId" ON "ContentTypes" ("LastModifierUserId"); + +CREATE INDEX "IX_DeletedContentItems_ContentTypeId" ON "DeletedContentItems" ("ContentTypeId"); + +CREATE INDEX "IX_DeletedContentItems_CreatorUserId" ON "DeletedContentItems" ("CreatorUserId"); + +CREATE INDEX "IX_DeletedContentItems_LastModifierUserId" ON "DeletedContentItems" ("LastModifierUserId"); + +CREATE INDEX "IX_EmailTemplateRevisions_CreatorUserId" ON "EmailTemplateRevisions" ("CreatorUserId"); + +CREATE INDEX "IX_EmailTemplateRevisions_EmailTemplateId" ON "EmailTemplateRevisions" ("EmailTemplateId"); + +CREATE INDEX "IX_EmailTemplateRevisions_LastModifierUserId" ON "EmailTemplateRevisions" ("LastModifierUserId"); + +CREATE INDEX "IX_EmailTemplates_CreatorUserId" ON "EmailTemplates" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_EmailTemplates_DeveloperName" ON "EmailTemplates" ("DeveloperName"); + +CREATE INDEX "IX_EmailTemplates_LastModifierUserId" ON "EmailTemplates" ("LastModifierUserId"); + +CREATE UNIQUE INDEX "IX_JwtLogins_Jti" ON "JwtLogins" ("Jti"); + +CREATE INDEX "IX_MediaItems_CreatorUserId" ON "MediaItems" ("CreatorUserId"); + +CREATE INDEX "IX_MediaItems_LastModifierUserId" ON "MediaItems" ("LastModifierUserId"); + +CREATE INDEX "IX_MediaItems_ObjectKey" ON "MediaItems" ("ObjectKey"); + +CREATE INDEX "IX_NavigationMenuItems_CreatorUserId" ON "NavigationMenuItems" ("CreatorUserId"); + +CREATE INDEX "IX_NavigationMenuItems_LastModifierUserId" ON "NavigationMenuItems" ("LastModifierUserId"); + +CREATE INDEX "IX_NavigationMenuItems_NavigationMenuId" ON "NavigationMenuItems" ("NavigationMenuId"); + +CREATE INDEX "IX_NavigationMenuItems_ParentNavigationMenuItemId" ON "NavigationMenuItems" ("ParentNavigationMenuItemId"); + +CREATE INDEX "IX_NavigationMenuRevisions_CreatorUserId" ON "NavigationMenuRevisions" ("CreatorUserId"); + +CREATE INDEX "IX_NavigationMenuRevisions_LastModifierUserId" ON "NavigationMenuRevisions" ("LastModifierUserId"); + +CREATE INDEX "IX_NavigationMenuRevisions_NavigationMenuId" ON "NavigationMenuRevisions" ("NavigationMenuId"); + +CREATE INDEX "IX_NavigationMenus_CreatorUserId" ON "NavigationMenus" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_NavigationMenus_DeveloperName" ON "NavigationMenus" ("DeveloperName"); + +CREATE INDEX "IX_NavigationMenus_LastModifierUserId" ON "NavigationMenus" ("LastModifierUserId"); + +CREATE INDEX "IX_OneTimePasswords_UserId" ON "OneTimePasswords" ("UserId"); + +CREATE INDEX "IX_RaythaFunctionRevisions_CreatorUserId" ON "RaythaFunctionRevisions" ("CreatorUserId"); + +CREATE INDEX "IX_RaythaFunctionRevisions_LastModifierUserId" ON "RaythaFunctionRevisions" ("LastModifierUserId"); + +CREATE INDEX "IX_RaythaFunctionRevisions_RaythaFunctionId" ON "RaythaFunctionRevisions" ("RaythaFunctionId"); + +CREATE INDEX "IX_RaythaFunctions_CreatorUserId" ON "RaythaFunctions" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_RaythaFunctions_DeveloperName" ON "RaythaFunctions" ("DeveloperName"); + +CREATE INDEX "IX_RaythaFunctions_LastModifierUserId" ON "RaythaFunctions" ("LastModifierUserId"); + +CREATE INDEX "IX_Roles_CreatorUserId" ON "Roles" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_Roles_DeveloperName" ON "Roles" ("DeveloperName"); + +CREATE INDEX "IX_Roles_LastModifierUserId" ON "Roles" ("LastModifierUserId"); + +CREATE INDEX "IX_RoleUser_UsersId" ON "RoleUser" ("UsersId"); + +CREATE UNIQUE INDEX "IX_Routes_Path" ON "Routes" ("Path"); + +CREATE INDEX "IX_ThemeAccessToMediaItems_MediaItemId" ON "ThemeAccessToMediaItems" ("MediaItemId"); + +CREATE INDEX "IX_ThemeAccessToMediaItems_ThemeId" ON "ThemeAccessToMediaItems" ("ThemeId"); + +CREATE INDEX "IX_Themes_CreatorUserId" ON "Themes" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_Themes_DeveloperName" ON "Themes" ("DeveloperName"); + +CREATE INDEX "IX_Themes_LastModifierUserId" ON "Themes" ("LastModifierUserId"); + +CREATE INDEX "IX_UserGroups_CreatorUserId" ON "UserGroups" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_UserGroups_DeveloperName" ON "UserGroups" ("DeveloperName"); + +CREATE INDEX "IX_UserGroups_LastModifierUserId" ON "UserGroups" ("LastModifierUserId"); + +CREATE INDEX "IX_Users_AuthenticationSchemeId" ON "Users" ("AuthenticationSchemeId"); + +CREATE INDEX "IX_Users_CreatorUserId" ON "Users" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_Users_EmailAddress" ON "Users" ("EmailAddress"); + +CREATE INDEX "IX_Users_LastModifierUserId" ON "Users" ("LastModifierUserId"); + +CREATE UNIQUE INDEX "IX_Users_SsoId_AuthenticationSchemeId" ON "Users" ("SsoId", "AuthenticationSchemeId"); + +CREATE INDEX "IX_UserUserGroup_UsersId" ON "UserUserGroup" ("UsersId"); + +CREATE INDEX "IX_UserView_UserFavoritesId" ON "UserView" ("UserFavoritesId"); + +CREATE INDEX "IX_VerificationCodes_CreatorUserId" ON "VerificationCodes" ("CreatorUserId"); + +CREATE INDEX "IX_VerificationCodes_LastModifierUserId" ON "VerificationCodes" ("LastModifierUserId"); + +CREATE INDEX "IX_Views_ContentTypeId" ON "Views" ("ContentTypeId"); + +CREATE INDEX "IX_Views_CreatorUserId" ON "Views" ("CreatorUserId"); + +CREATE INDEX "IX_Views_LastModifierUserId" ON "Views" ("LastModifierUserId"); + +CREATE UNIQUE INDEX "IX_Views_RouteId" ON "Views" ("RouteId"); + +CREATE INDEX "IX_WebTemplateAccessToModelDefinitions_ContentTypeId" ON "WebTemplateAccessToModelDefinitions" ("ContentTypeId"); + +CREATE INDEX "IX_WebTemplateAccessToModelDefinitions_WebTemplateId" ON "WebTemplateAccessToModelDefinitions" ("WebTemplateId"); + +CREATE INDEX "IX_WebTemplateContentItemRelations_ContentItemId" ON "WebTemplateContentItemRelations" ("ContentItemId"); + +CREATE UNIQUE INDEX "IX_WebTemplateContentItemRelations_WebTemplateId_ContentItemId" ON "WebTemplateContentItemRelations" ("WebTemplateId", "ContentItemId"); + +CREATE INDEX "IX_WebTemplateRevisions_CreatorUserId" ON "WebTemplateRevisions" ("CreatorUserId"); + +CREATE INDEX "IX_WebTemplateRevisions_EmailTemplateId" ON "WebTemplateRevisions" ("EmailTemplateId"); + +CREATE INDEX "IX_WebTemplateRevisions_LastModifierUserId" ON "WebTemplateRevisions" ("LastModifierUserId"); + +CREATE INDEX "IX_WebTemplateRevisions_WebTemplateId" ON "WebTemplateRevisions" ("WebTemplateId"); + +CREATE INDEX "IX_WebTemplates_CreatorUserId" ON "WebTemplates" ("CreatorUserId"); + +CREATE UNIQUE INDEX "IX_WebTemplates_DeveloperName_ThemeId" ON "WebTemplates" ("DeveloperName", "ThemeId"); + +CREATE INDEX "IX_WebTemplates_LastModifierUserId" ON "WebTemplates" ("LastModifierUserId"); + +CREATE INDEX "IX_WebTemplates_ParentTemplateId" ON "WebTemplates" ("ParentTemplateId"); + +CREATE INDEX "IX_WebTemplates_ThemeId" ON "WebTemplates" ("ThemeId"); + +CREATE UNIQUE INDEX "IX_WebTemplateViewRelations_ViewId_WebTemplateId" ON "WebTemplateViewRelations" ("ViewId", "WebTemplateId"); + +CREATE INDEX "IX_WebTemplateViewRelations_WebTemplateId" ON "WebTemplateViewRelations" ("WebTemplateId"); + +ALTER TABLE "ApiKeys" ADD CONSTRAINT "FK_ApiKeys_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"); + +ALTER TABLE "ApiKeys" ADD CONSTRAINT "FK_ApiKeys_Users_UserId" FOREIGN KEY ("UserId") REFERENCES "Users" ("Id") ON DELETE CASCADE; + +ALTER TABLE "AuthenticationSchemes" ADD CONSTRAINT "FK_AuthenticationSchemes_Users_CreatorUserId" FOREIGN KEY ("CreatorUserId") REFERENCES "Users" ("Id"); + +ALTER TABLE "AuthenticationSchemes" ADD CONSTRAINT "FK_AuthenticationSchemes_Users_LastModifierUserId" FOREIGN KEY ("LastModifierUserId") REFERENCES "Users" ("Id"); + +INSERT INTO "NavigationMenus" ("Id", "Label", "DeveloperName", "IsMainMenu", "CreationTime") +VALUES ('ba0ccdb4-8fa5-4e83-86bd-cfcf083e09b1', 'Main menu', 'mainmenu', TRUE, TIMESTAMPTZ '2024-11-16T19:40:17.781995Z'); + +INSERT INTO "NavigationMenuItems" ("Id", "Label", "Url", "IsDisabled", "OpenInNewTab", "CssClassName", "Ordinal", "NavigationMenuId", "CreationTime") +VALUES ('29aea7ee-1df9-4516-87ea-2d13d51b77a8', 'Home', '/home', FALSE, FALSE, 'nav-link', 1, 'ba0ccdb4-8fa5-4e83-86bd-cfcf083e09b1', TIMESTAMPTZ '2024-11-16T19:40:17.782483Z'); +INSERT INTO "NavigationMenuItems" ("Id", "Label", "Url", "IsDisabled", "OpenInNewTab", "CssClassName", "Ordinal", "NavigationMenuId", "CreationTime") +VALUES ('02a9a0e4-8859-48de-b439-b4f893643a40', 'About', '/about', FALSE, FALSE, 'nav-link', 2, 'ba0ccdb4-8fa5-4e83-86bd-cfcf083e09b1', TIMESTAMPTZ '2024-11-16T19:40:17.782483Z'); +INSERT INTO "NavigationMenuItems" ("Id", "Label", "Url", "IsDisabled", "OpenInNewTab", "CssClassName", "Ordinal", "NavigationMenuId", "CreationTime") +VALUES ('70115076-6bff-4303-a876-8573b60d9210', 'Posts', '/posts', FALSE, FALSE, 'nav-link', 3, 'ba0ccdb4-8fa5-4e83-86bd-cfcf083e09b1', TIMESTAMPTZ '2024-11-16T19:40:17.782484Z'); + +INSERT INTO "Themes" ("Id", "Title", "DeveloperName", "IsExportable", "Description", "CreationTime") +VALUES ('e567f9ce-089f-403f-a399-211ac60cf2d1', 'Raytha default theme', 'raytha_default_theme', FALSE, 'Raytha default theme', TIMESTAMPTZ '2024-11-16T19:40:17.782485Z'); + +INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") +VALUES ('20241110181505_v1_4_0', '8.0.10'); + +COMMIT; + diff --git a/db/FreshCreateOnLatestVersion.sql b/db/SqlServer/FreshCreateOnLatestVersion.sql similarity index 92% rename from db/FreshCreateOnLatestVersion.sql rename to db/SqlServer/FreshCreateOnLatestVersion.sql index cf51f3eb..e18e606d 100644 --- a/db/FreshCreateOnLatestVersion.sql +++ b/db/SqlServer/FreshCreateOnLatestVersion.sql @@ -653,7 +653,7 @@ ALTER TABLE [AuthenticationSchemes] ADD CONSTRAINT [FK_AuthenticationSchemes_Use GO INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20221230221303_v0_9_0', N'7.0.1'); +VALUES (N'20221230221303_v0_9_0', N'8.0.10'); GO COMMIT; @@ -704,7 +704,7 @@ CREATE INDEX [IX_ApiKeys_UserId] ON [ApiKeys] ([UserId]); GO INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20230211205159_v1_0_0', N'7.0.1'); +VALUES (N'20230211205159_v1_0_0', N'8.0.10'); GO COMMIT; @@ -730,10 +730,6 @@ CREATE TABLE [BackgroundTasks] ( ); GO -INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20230521175706_v1_1_0', N'7.0.1'); -GO - COMMIT; GO @@ -743,6 +739,16 @@ GO BEGIN TRANSACTION; GO +INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) +VALUES (N'20230521175706_v1_1_0', N'8.0.10'); +GO + +COMMIT; +GO + +BEGIN TRANSACTION; +GO + CREATE TABLE [RaythaFunctions] ( [Id] uniqueidentifier NOT NULL, [Name] nvarchar(max) NOT NULL, @@ -794,7 +800,7 @@ CREATE INDEX [IX_RaythaFunctions_LastModifierUserId] ON [RaythaFunctions] ([Last GO INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20240314124844_v1_2_0', N'8.0.0'); +VALUES (N'20240314124844_v1_2_0', N'8.0.10'); GO COMMIT; @@ -888,7 +894,7 @@ GO IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Label', N'DeveloperName', N'IsMainMenu', N'CreationTime') AND [object_id] = OBJECT_ID(N'[NavigationMenus]')) SET IDENTITY_INSERT [NavigationMenus] ON; INSERT INTO [NavigationMenus] ([Id], [Label], [DeveloperName], [IsMainMenu], [CreationTime]) -VALUES ('b49f9abf-8e2c-4c25-950c-0ced2f378a37', N'Main menu', N'mainmenu', CAST(1 AS bit), '2024-09-03T09:38:27.0216661Z'); +VALUES ('03ed3a83-d30d-4785-a882-eaac824b4cf5', N'Main menu', N'mainmenu', CAST(1 AS bit), '2024-11-16T19:33:33.8478785Z'); IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Label', N'DeveloperName', N'IsMainMenu', N'CreationTime') AND [object_id] = OBJECT_ID(N'[NavigationMenus]')) SET IDENTITY_INSERT [NavigationMenus] OFF; GO @@ -896,9 +902,9 @@ GO IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Label', N'Url', N'IsDisabled', N'OpenInNewTab', N'CssClassName', N'Ordinal', N'NavigationMenuId', N'CreationTime') AND [object_id] = OBJECT_ID(N'[NavigationMenuItems]')) SET IDENTITY_INSERT [NavigationMenuItems] ON; INSERT INTO [NavigationMenuItems] ([Id], [Label], [Url], [IsDisabled], [OpenInNewTab], [CssClassName], [Ordinal], [NavigationMenuId], [CreationTime]) -VALUES ('5982c677-5f8e-4134-8870-84227258f6e0', N'Home', N'/home', CAST(0 AS bit), CAST(0 AS bit), N'nav-link', 1, 'b49f9abf-8e2c-4c25-950c-0ced2f378a37', '2024-09-03T09:38:27.0222388Z'), -('ed7dfb20-e443-4212-8c24-4365d0d5f1e3', N'About', N'/about', CAST(0 AS bit), CAST(0 AS bit), N'nav-link', 2, 'b49f9abf-8e2c-4c25-950c-0ced2f378a37', '2024-09-03T09:38:27.0222392Z'), -('ac03cd99-5fb8-452d-9aa1-8047c040fcb2', N'Posts', N'/posts', CAST(0 AS bit), CAST(0 AS bit), N'nav-link', 3, 'b49f9abf-8e2c-4c25-950c-0ced2f378a37', '2024-09-03T09:38:27.0222398Z'); +VALUES ('b55bd326-8bc7-4210-af6e-9ed6cc85ca79', N'Home', N'/home', CAST(0 AS bit), CAST(0 AS bit), N'nav-link', 1, '03ed3a83-d30d-4785-a882-eaac824b4cf5', '2024-11-16T19:33:33.8484313Z'), +('aa4627f0-c3b6-4631-b097-913648fdc44b', N'About', N'/about', CAST(0 AS bit), CAST(0 AS bit), N'nav-link', 2, '03ed3a83-d30d-4785-a882-eaac824b4cf5', '2024-11-16T19:33:33.8484332Z'), +('b25bd839-95d6-45f4-b817-e14e3b64e048', N'Posts', N'/posts', CAST(0 AS bit), CAST(0 AS bit), N'nav-link', 3, '03ed3a83-d30d-4785-a882-eaac824b4cf5', '2024-11-16T19:33:33.8484335Z'); IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Label', N'Url', N'IsDisabled', N'OpenInNewTab', N'CssClassName', N'Ordinal', N'NavigationMenuId', N'CreationTime') AND [object_id] = OBJECT_ID(N'[NavigationMenuItems]')) SET IDENTITY_INSERT [NavigationMenuItems] OFF; GO @@ -943,15 +949,15 @@ GO IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Title', N'DeveloperName', N'IsExportable', N'Description', N'CreationTime') AND [object_id] = OBJECT_ID(N'[Themes]')) SET IDENTITY_INSERT [Themes] ON; INSERT INTO [Themes] ([Id], [Title], [DeveloperName], [IsExportable], [Description], [CreationTime]) -VALUES ('944ca79b-1ce5-47c4-8557-c8e6172df1dd', N'Raytha default theme', N'raytha_default_theme', CAST(0 AS bit), N'Raytha default theme', '2024-09-03T09:38:27.0238368Z'); +VALUES ('ee7046a6-4bba-40d6-a545-ebdb972167c6', N'Raytha default theme', N'raytha_default_theme', CAST(0 AS bit), N'Raytha default theme', '2024-11-16T19:33:33.8495914Z'); IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Title', N'DeveloperName', N'IsExportable', N'Description', N'CreationTime') AND [object_id] = OBJECT_ID(N'[Themes]')) SET IDENTITY_INSERT [Themes] OFF; GO -ALTER TABLE [WebTemplates] ADD [ThemeId] uniqueidentifier NOT NULL DEFAULT '944ca79b-1ce5-47c4-8557-c8e6172df1dd'; +ALTER TABLE [WebTemplates] ADD [ThemeId] uniqueidentifier NOT NULL DEFAULT 'ee7046a6-4bba-40d6-a545-ebdb972167c6'; GO -ALTER TABLE [OrganizationSettings] ADD [ActiveThemeId] uniqueidentifier NOT NULL DEFAULT '944ca79b-1ce5-47c4-8557-c8e6172df1dd'; +ALTER TABLE [OrganizationSettings] ADD [ActiveThemeId] uniqueidentifier NOT NULL DEFAULT 'ee7046a6-4bba-40d6-a545-ebdb972167c6'; GO ALTER TABLE [ContentItems] DROP CONSTRAINT [FK_ContentItems_WebTemplates_WebTemplateId]; @@ -1064,13 +1070,84 @@ GO ALTER TABLE [WebTemplates] ADD CONSTRAINT [FK_WebTemplates_Themes_ThemeId] FOREIGN KEY ([ThemeId]) REFERENCES [Themes] ([Id]) ON DELETE CASCADE; GO +INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) +VALUES (N'20240502121207_v1_3_0', N'8.0.10'); +GO + +COMMIT; +GO + +BEGIN TRANSACTION; +GO + +DROP INDEX [IX_WebTemplates_DeveloperName_ThemeId] ON [WebTemplates]; +GO + +DROP INDEX [IX_Users_EmailAddress] ON [Users]; +GO + +DROP INDEX [IX_Users_SsoId_AuthenticationSchemeId] ON [Users]; +GO + +DROP INDEX [IX_UserGroups_DeveloperName] ON [UserGroups]; +GO + +DROP INDEX [IX_Routes_Path] ON [Routes]; +GO + +DROP INDEX [IX_Roles_DeveloperName] ON [Roles]; +GO + +DROP INDEX [IX_JwtLogins_Jti] ON [JwtLogins]; +GO + +DROP INDEX [IX_AuthenticationSchemes_DeveloperName] ON [AuthenticationSchemes]; +GO + +DECLARE @var3 sysname; +SELECT @var3 = [d].[name] +FROM [sys].[default_constraints] [d] +INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id] +WHERE ([d].[parent_object_id] = OBJECT_ID(N'[EmailTemplates]') AND [c].[name] = N'DeveloperName'); +IF @var3 IS NOT NULL EXEC(N'ALTER TABLE [EmailTemplates] DROP CONSTRAINT [' + @var3 + '];'); +ALTER TABLE [EmailTemplates] ALTER COLUMN [DeveloperName] nvarchar(450) NULL; +GO + +CREATE UNIQUE INDEX [IX_WebTemplates_DeveloperName_ThemeId] ON [WebTemplates] ([DeveloperName], [ThemeId]) WHERE [DeveloperName] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_Users_EmailAddress] ON [Users] ([EmailAddress]); +GO + +CREATE UNIQUE INDEX [IX_Users_SsoId_AuthenticationSchemeId] ON [Users] ([SsoId], [AuthenticationSchemeId]) WHERE [SsoId] IS NOT NULL AND [AuthenticationSchemeId] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_UserGroups_DeveloperName] ON [UserGroups] ([DeveloperName]); +GO + +CREATE UNIQUE INDEX [IX_Routes_Path] ON [Routes] ([Path]); +GO + +CREATE UNIQUE INDEX [IX_Roles_DeveloperName] ON [Roles] ([DeveloperName]); +GO + +CREATE UNIQUE INDEX [IX_JwtLogins_Jti] ON [JwtLogins] ([Jti]) WHERE [Jti] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_EmailTemplates_DeveloperName] ON [EmailTemplates] ([DeveloperName]) WHERE [DeveloperName] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_AuthenticationSchemes_DeveloperName] ON [AuthenticationSchemes] ([DeveloperName]) WHERE [DeveloperName] IS NOT NULL; +GO + INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) VALUES ('20221230221303_v0_9_0', 'FreshCreateOnLatestVersion'), ('20230211205159_v1_0_0', 'FreshCreateOnLatestVersion'), ('20230521175706_v1_1_0', 'FreshCreateOnLatestVersion'), ('20240314124844_v1_2_0', 'FreshCreateOnLatestVersion'), -('20240502121207_v1_3_0', 'FreshCreateOnLatestVersion'); +('20240502121207_v1_3_0', 'FreshCreateOnLatestVersion'), +('20241116192521_v1_4_0', 'FreshCreateOnLatestVersion'); GO COMMIT; diff --git a/db/v0_0_0_to_v0_9_0.sql b/db/SqlServer/v0_0_0_to_v0_9_0.sql similarity index 100% rename from db/v0_0_0_to_v0_9_0.sql rename to db/SqlServer/v0_0_0_to_v0_9_0.sql diff --git a/db/v0_9_0_to_v1_0_0.sql b/db/SqlServer/v0_9_0_to_v1_0_0.sql similarity index 100% rename from db/v0_9_0_to_v1_0_0.sql rename to db/SqlServer/v0_9_0_to_v1_0_0.sql diff --git a/db/v1_0_0_to_v1_1_0.sql b/db/SqlServer/v1_0_0_to_v1_1_0.sql similarity index 100% rename from db/v1_0_0_to_v1_1_0.sql rename to db/SqlServer/v1_0_0_to_v1_1_0.sql diff --git a/db/v1_1_0_to_v1_2_0.sql b/db/SqlServer/v1_1_0_to_v1_2_0.sql similarity index 100% rename from db/v1_1_0_to_v1_2_0.sql rename to db/SqlServer/v1_1_0_to_v1_2_0.sql diff --git a/db/v1_2_0_to_v1_3_0.sql b/db/SqlServer/v1_2_0_to_v1_3_0.sql similarity index 100% rename from db/v1_2_0_to_v1_3_0.sql rename to db/SqlServer/v1_2_0_to_v1_3_0.sql diff --git a/db/SqlServer/v1_3_0_to_v1_4_0.sql b/db/SqlServer/v1_3_0_to_v1_4_0.sql new file mode 100644 index 00000000..81f35125 --- /dev/null +++ b/db/SqlServer/v1_3_0_to_v1_4_0.sql @@ -0,0 +1,70 @@ +BEGIN TRANSACTION; +GO + +DROP INDEX [IX_WebTemplates_DeveloperName_ThemeId] ON [WebTemplates]; +GO + +DROP INDEX [IX_Users_EmailAddress] ON [Users]; +GO + +DROP INDEX [IX_Users_SsoId_AuthenticationSchemeId] ON [Users]; +GO + +DROP INDEX [IX_UserGroups_DeveloperName] ON [UserGroups]; +GO + +DROP INDEX [IX_Routes_Path] ON [Routes]; +GO + +DROP INDEX [IX_Roles_DeveloperName] ON [Roles]; +GO + +DROP INDEX [IX_JwtLogins_Jti] ON [JwtLogins]; +GO + +DROP INDEX [IX_AuthenticationSchemes_DeveloperName] ON [AuthenticationSchemes]; +GO + +DECLARE @var0 sysname; +SELECT @var0 = [d].[name] +FROM [sys].[default_constraints] [d] +INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id] +WHERE ([d].[parent_object_id] = OBJECT_ID(N'[EmailTemplates]') AND [c].[name] = N'DeveloperName'); +IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [EmailTemplates] DROP CONSTRAINT [' + @var0 + '];'); +ALTER TABLE [EmailTemplates] ALTER COLUMN [DeveloperName] nvarchar(450) NULL; +GO + +CREATE UNIQUE INDEX [IX_WebTemplates_DeveloperName_ThemeId] ON [WebTemplates] ([DeveloperName], [ThemeId]) WHERE [DeveloperName] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_Users_EmailAddress] ON [Users] ([EmailAddress]); +GO + +CREATE UNIQUE INDEX [IX_Users_SsoId_AuthenticationSchemeId] ON [Users] ([SsoId], [AuthenticationSchemeId]) WHERE [SsoId] IS NOT NULL AND [AuthenticationSchemeId] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_UserGroups_DeveloperName] ON [UserGroups] ([DeveloperName]); +GO + +CREATE UNIQUE INDEX [IX_Routes_Path] ON [Routes] ([Path]); +GO + +CREATE UNIQUE INDEX [IX_Roles_DeveloperName] ON [Roles] ([DeveloperName]); +GO + +CREATE UNIQUE INDEX [IX_JwtLogins_Jti] ON [JwtLogins] ([Jti]) WHERE [Jti] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_EmailTemplates_DeveloperName] ON [EmailTemplates] ([DeveloperName]) WHERE [DeveloperName] IS NOT NULL; +GO + +CREATE UNIQUE INDEX [IX_AuthenticationSchemes_DeveloperName] ON [AuthenticationSchemes] ([DeveloperName]) WHERE [DeveloperName] IS NOT NULL; +GO + +INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) +VALUES (N'20241116192521_v1_4_0', N'8.0.10'); +GO + +COMMIT; +GO + diff --git a/src/Raytha.Infrastructure/Persistence/RaythaDbContext.cs b/src/Raytha.Infrastructure/Persistence/RaythaDbContext.cs index 361fb4ae..148d1192 100644 --- a/src/Raytha.Infrastructure/Persistence/RaythaDbContext.cs +++ b/src/Raytha.Infrastructure/Persistence/RaythaDbContext.cs @@ -72,7 +72,6 @@ public RaythaDbContext( protected override void OnModelCreating(ModelBuilder builder) { - builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly(), p => p.GetInterfaces().All(c => c.Name != typeof(ISqlServerConfiguration).Name && c.Name != typeof(IPostgresConfiguration).Name)); var dbProvider = DbProviderHelper.GetDatabaseProviderTypeFromConnectionString(_configuration.GetConnectionString("DefaultConnection")); if (dbProvider == DatabaseProviderType.Postgres) diff --git a/src/Raytha.Migrations.SqlServer/20241116192521_v1_4_0.Designer.cs b/src/Raytha.Migrations.SqlServer/20241116192521_v1_4_0.Designer.cs new file mode 100644 index 00000000..85ce3f5f --- /dev/null +++ b/src/Raytha.Migrations.SqlServer/20241116192521_v1_4_0.Designer.cs @@ -0,0 +1,2276 @@ +// <auto-generated /> +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Raytha.Infrastructure.Persistence; + +#nullable disable + +namespace Raytha.Migrations.SqlServer +{ + [DbContext(typeof(RaythaDbContext))] + [Migration("20241116192521_v1_4_0")] + partial class v1_4_0 + { + /// <inheritdoc /> + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); + + b.Property<string>("FriendlyName") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Xml") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ApiKey", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<byte[]>("ApiKeyHash") + .IsRequired() + .HasColumnType("varbinary(900)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ApiKeyHash") + .IsUnique(); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("UserId"); + + b.ToTable("ApiKeys"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.AuditLog", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Category") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("EntityId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("IpAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Request") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("UserEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Category"); + + b.HasIndex("CreationTime"); + + b.HasIndex("EntityId"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.AuthenticationScheme", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("AuthenticationSchemeType") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DeveloperName") + .HasColumnType("nvarchar(450)"); + + b.Property<bool>("IsBuiltInAuth") + .HasColumnType("bit"); + + b.Property<bool>("IsEnabledForAdmins") + .HasColumnType("bit"); + + b.Property<bool>("IsEnabledForUsers") + .HasColumnType("bit"); + + b.Property<string>("JwtSecretKey") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("JwtUseHighSecurity") + .HasColumnType("bit"); + + b.Property<string>("Label") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("LoginButtonText") + .HasColumnType("nvarchar(max)"); + + b.Property<int>("MagicLinkExpiresInSeconds") + .HasColumnType("int"); + + b.Property<string>("SamlCertificate") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("SamlIdpEntityId") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("SignInUrl") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("SignOutUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("DeveloperName") + .IsUnique() + .HasFilter("[DeveloperName] IS NOT NULL"); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("AuthenticationSchemes"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.BackgroundTask", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Args") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("CompletionTime") + .HasColumnType("datetime2"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<string>("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<string>("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<int>("NumberOfRetries") + .HasColumnType("int"); + + b.Property<int>("PercentComplete") + .HasColumnType("int"); + + b.Property<string>("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("StatusInfo") + .HasColumnType("nvarchar(max)"); + + b.Property<int>("TaskStep") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("BackgroundTasks"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentItem", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<bool>("IsDraft") + .HasColumnType("bit"); + + b.Property<bool>("IsPublished") + .HasColumnType("bit"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("RouteId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("_DraftContent") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("_PublishedContent") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ContentTypeId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("RouteId") + .IsUnique(); + + b.ToTable("ContentItems"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentItemRevision", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentItemId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("_PublishedContent") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ContentItemId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("ContentItemRevisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentType", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DefaultRouteTemplate") + .HasColumnType("nvarchar(max)"); + + b.Property<Guid?>("DeleterUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("DeletionTime") + .HasColumnType("datetime2"); + + b.Property<string>("Description") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("DeveloperName") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("IsActive") + .HasColumnType("bit"); + + b.Property<bool>("IsDeleted") + .HasColumnType("bit"); + + b.Property<string>("LabelPlural") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("LabelSingular") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("PrimaryFieldId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("ContentTypes"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentTypeField", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid?>("DeleterUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("DeletionTime") + .HasColumnType("datetime2"); + + b.Property<string>("Description") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("DeveloperName") + .HasColumnType("nvarchar(max)"); + + b.Property<int>("FieldOrder") + .HasColumnType("int"); + + b.Property<string>("FieldType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("IsDeleted") + .HasColumnType("bit"); + + b.Property<bool>("IsRequired") + .HasColumnType("bit"); + + b.Property<string>("Label") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid?>("RelatedContentTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("_Choices") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ContentTypeId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("RelatedContentTypeId"); + + b.ToTable("ContentTypeFields"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentTypeRolePermission", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property<int>("ContentTypePermissions") + .HasColumnType("int"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ContentTypeId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("RoleId"); + + b.ToTable("ContentTypeRolePermission"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.DeletedContentItem", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("OriginalContentItemId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("PrimaryField") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("RoutePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("WebTemplateIdsJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("_PublishedContent") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ContentTypeId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("DeletedContentItems"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.EmailTemplate", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Bcc") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Cc") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Content") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DeveloperName") + .HasColumnType("nvarchar(450)"); + + b.Property<bool>("IsBuiltInTemplate") + .HasColumnType("bit"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Subject") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("DeveloperName") + .IsUnique() + .HasFilter("[DeveloperName] IS NOT NULL"); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("EmailTemplates"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.EmailTemplateRevision", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Bcc") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Cc") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Content") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("EmailTemplateId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Subject") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("EmailTemplateId"); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("EmailTemplateRevisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.JwtLogin", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<string>("Jti") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Jti") + .IsUnique() + .HasFilter("[Jti] IS NOT NULL"); + + b.ToTable("JwtLogins"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.MediaItem", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("ContentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("FileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("FileStorageProvider") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<long>("Length") + .HasColumnType("bigint"); + + b.Property<string>("ObjectKey") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("ObjectKey"); + + b.ToTable("MediaItems"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.NavigationMenu", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DeveloperName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<bool>("IsMainMenu") + .HasColumnType("bit"); + + b.Property<string>("Label") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("DeveloperName") + .IsUnique(); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("NavigationMenus"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.NavigationMenuItem", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("CssClassName") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("IsDisabled") + .HasColumnType("bit"); + + b.Property<string>("Label") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("NavigationMenuId") + .HasColumnType("uniqueidentifier"); + + b.Property<bool>("OpenInNewTab") + .HasColumnType("bit"); + + b.Property<int>("Ordinal") + .HasColumnType("int"); + + b.Property<Guid?>("ParentNavigationMenuItemId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Url") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("NavigationMenuId"); + + b.HasIndex("ParentNavigationMenuItemId"); + + b.ToTable("NavigationMenuItems"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.NavigationMenuRevision", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("NavigationMenuId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("NavigationMenuItemsJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("NavigationMenuId"); + + b.ToTable("NavigationMenuRevisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.OneTimePassword", b => + { + b.Property<byte[]>("Id") + .HasColumnType("varbinary(900)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<DateTime>("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property<bool>("IsUsed") + .HasColumnType("bit"); + + b.Property<Guid>("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("OneTimePasswords"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.OrganizationSettings", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ActiveThemeId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DateFormat") + .HasColumnType("nvarchar(max)"); + + b.Property<Guid?>("HomePageId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("HomePageType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("OrganizationName") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("SmtpDefaultFromAddress") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("SmtpDefaultFromName") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("SmtpHost") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("SmtpOverrideSystem") + .HasColumnType("bit"); + + b.Property<string>("SmtpPassword") + .HasColumnType("nvarchar(max)"); + + b.Property<int?>("SmtpPort") + .HasColumnType("int"); + + b.Property<string>("SmtpUsername") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("TimeZone") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("WebsiteUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OrganizationSettings"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.RaythaFunction", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DeveloperName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<bool>("IsActive") + .HasColumnType("bit"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("TriggerType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("DeveloperName") + .IsUnique(); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("RaythaFunctions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.RaythaFunctionRevision", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("RaythaFunctionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("RaythaFunctionId"); + + b.ToTable("RaythaFunctionRevisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Role", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DeveloperName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<string>("Label") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<int>("SystemPermissions") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("DeveloperName") + .IsUnique(); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Route", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentItemId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Path") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<Guid>("ViewId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("Path") + .IsUnique(); + + b.ToTable("Routes"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Theme", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("DeveloperName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<bool>("IsExportable") + .HasColumnType("bit"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("DeveloperName") + .IsUnique(); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("Themes"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ThemeAccessToMediaItem", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("MediaItemId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ThemeId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("MediaItemId"); + + b.HasIndex("ThemeId"); + + b.ToTable("ThemeAccessToMediaItems"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.User", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid?>("AuthenticationSchemeId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<string>("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("IsActive") + .HasColumnType("bit"); + + b.Property<bool>("IsAdmin") + .HasColumnType("bit"); + + b.Property<bool>("IsEmailAddressConfirmed") + .HasColumnType("bit"); + + b.Property<DateTime?>("LastLoggedInTime") + .HasColumnType("datetime2"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<byte[]>("PasswordHash") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property<byte[]>("Salt") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property<string>("SsoId") + .HasColumnType("nvarchar(450)"); + + b.Property<string>("_RecentlyAccessedViews") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AuthenticationSchemeId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("EmailAddress") + .IsUnique(); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("SsoId", "AuthenticationSchemeId") + .IsUnique() + .HasFilter("[SsoId] IS NOT NULL AND [AuthenticationSchemeId] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.UserGroup", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DeveloperName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property<string>("Label") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("DeveloperName") + .IsUnique(); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("UserGroups"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.VerificationCode", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("Code") + .HasColumnType("uniqueidentifier"); + + b.Property<bool>("Completed") + .HasColumnType("bit"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("VerificationCodeType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.ToTable("VerificationCodes"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.View", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<int>("DefaultNumberOfItemsPerPage") + .HasColumnType("int"); + + b.Property<string>("Description") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("DeveloperName") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("IgnoreClientFilterAndSortQueryParams") + .HasColumnType("bit"); + + b.Property<bool>("IsPublished") + .HasColumnType("bit"); + + b.Property<string>("Label") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<int>("MaxNumberOfItemsPerPage") + .HasColumnType("int"); + + b.Property<Guid>("RouteId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("_Columns") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("_Filter") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("_Sort") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ContentTypeId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("RouteId") + .IsUnique(); + + b.ToTable("Views"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplate", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<bool>("AllowAccessForNewContentTypes") + .HasColumnType("bit"); + + b.Property<string>("Content") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("DeveloperName") + .HasColumnType("nvarchar(450)"); + + b.Property<bool>("IsBaseLayout") + .HasColumnType("bit"); + + b.Property<bool>("IsBuiltInTemplate") + .HasColumnType("bit"); + + b.Property<string>("Label") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid?>("ParentTemplateId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ThemeId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("ParentTemplateId"); + + b.HasIndex("ThemeId"); + + b.HasIndex("DeveloperName", "ThemeId") + .IsUnique() + .HasFilter("[DeveloperName] IS NOT NULL"); + + b.ToTable("WebTemplates"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateAccessToModelDefinition", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("WebTemplateId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ContentTypeId"); + + b.HasIndex("WebTemplateId"); + + b.ToTable("WebTemplateAccessToModelDefinitions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateContentItemRelation", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ContentItemId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("WebTemplateId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ContentItemId"); + + b.HasIndex("WebTemplateId", "ContentItemId") + .IsUnique(); + + b.ToTable("WebTemplateContentItemRelations"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateRevision", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<bool>("AllowAccessForNewContentTypes") + .HasColumnType("bit"); + + b.Property<string>("Content") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("CreationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("CreatorUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid?>("EmailTemplateId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Label") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime?>("LastModificationTime") + .HasColumnType("datetime2"); + + b.Property<Guid?>("LastModifierUserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("WebTemplateId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("EmailTemplateId"); + + b.HasIndex("LastModifierUserId"); + + b.HasIndex("WebTemplateId"); + + b.ToTable("WebTemplateRevisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateViewRelation", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("ViewId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("WebTemplateId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("WebTemplateId"); + + b.HasIndex("ViewId", "WebTemplateId") + .IsUnique(); + + b.ToTable("WebTemplateViewRelations"); + }); + + modelBuilder.Entity("RoleUser", b => + { + b.Property<Guid>("RolesId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("UsersId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("RolesId", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("RoleUser"); + }); + + modelBuilder.Entity("UserUserGroup", b => + { + b.Property<Guid>("UserGroupsId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("UsersId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("UserGroupsId", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("UserUserGroup"); + }); + + modelBuilder.Entity("UserView", b => + { + b.Property<Guid>("FavoriteViewsId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("UserFavoritesId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FavoriteViewsId", "UserFavoritesId"); + + b.HasIndex("UserFavoritesId"); + + b.ToTable("UserView"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ApiKey", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "User") + .WithMany("ApiKeys") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatorUser"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.AuthenticationScheme", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentItem", b => + { + b.HasOne("Raytha.Domain.Entities.ContentType", "ContentType") + .WithMany() + .HasForeignKey("ContentTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.Route", "Route") + .WithOne("ContentItem") + .HasForeignKey("Raytha.Domain.Entities.ContentItem", "RouteId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ContentType"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("Route"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentItemRevision", b => + { + b.HasOne("Raytha.Domain.Entities.ContentItem", "ContentItem") + .WithMany("ContentItemRevisions") + .HasForeignKey("ContentItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("ContentItem"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentType", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentTypeField", b => + { + b.HasOne("Raytha.Domain.Entities.ContentType", "ContentType") + .WithMany("ContentTypeFields") + .HasForeignKey("ContentTypeId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.ContentType", "RelatedContentType") + .WithMany() + .HasForeignKey("RelatedContentTypeId"); + + b.Navigation("ContentType"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("RelatedContentType"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentTypeRolePermission", b => + { + b.HasOne("Raytha.Domain.Entities.ContentType", "ContentType") + .WithMany() + .HasForeignKey("ContentTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.Role", "Role") + .WithMany("ContentTypeRolePermissions") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ContentType"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.DeletedContentItem", b => + { + b.HasOne("Raytha.Domain.Entities.ContentType", "ContentType") + .WithMany() + .HasForeignKey("ContentTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("ContentType"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.EmailTemplate", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.EmailTemplateRevision", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.EmailTemplate", "EmailTemplate") + .WithMany() + .HasForeignKey("EmailTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("EmailTemplate"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.MediaItem", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.NavigationMenu", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.NavigationMenuItem", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.NavigationMenu", "NavigationMenu") + .WithMany("NavigationMenuItems") + .HasForeignKey("NavigationMenuId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.NavigationMenuItem", "ParentNavigationMenuItem") + .WithMany() + .HasForeignKey("ParentNavigationMenuItemId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("NavigationMenu"); + + b.Navigation("ParentNavigationMenuItem"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.NavigationMenuRevision", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.NavigationMenu", "NavigationMenu") + .WithMany("NavigationMenuRevisions") + .HasForeignKey("NavigationMenuId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("NavigationMenu"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.OneTimePassword", b => + { + b.HasOne("Raytha.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.RaythaFunction", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.RaythaFunctionRevision", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.RaythaFunction", "RaythaFunction") + .WithMany("Revisions") + .HasForeignKey("RaythaFunctionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("RaythaFunction"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Role", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Theme", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ThemeAccessToMediaItem", b => + { + b.HasOne("Raytha.Domain.Entities.MediaItem", "MediaItem") + .WithMany() + .HasForeignKey("MediaItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.Theme", "Theme") + .WithMany("ThemeAccessToMediaItems") + .HasForeignKey("ThemeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MediaItem"); + + b.Navigation("Theme"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.User", b => + { + b.HasOne("Raytha.Domain.Entities.AuthenticationScheme", "AuthenticationScheme") + .WithMany() + .HasForeignKey("AuthenticationSchemeId") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("AuthenticationScheme"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.UserGroup", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.VerificationCode", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.View", b => + { + b.HasOne("Raytha.Domain.Entities.ContentType", "ContentType") + .WithMany("Views") + .HasForeignKey("ContentTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("Raytha.Domain.Entities.Route", "Route") + .WithOne("View") + .HasForeignKey("Raytha.Domain.Entities.View", "RouteId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ContentType"); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("Route"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplate", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.WebTemplate", "ParentTemplate") + .WithMany() + .HasForeignKey("ParentTemplateId"); + + b.HasOne("Raytha.Domain.Entities.Theme", "Theme") + .WithMany("WebTemplates") + .HasForeignKey("ThemeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("ParentTemplate"); + + b.Navigation("Theme"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateAccessToModelDefinition", b => + { + b.HasOne("Raytha.Domain.Entities.ContentType", "ContentType") + .WithMany() + .HasForeignKey("ContentTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.WebTemplate", "WebTemplate") + .WithMany("TemplateAccessToModelDefinitions") + .HasForeignKey("WebTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ContentType"); + + b.Navigation("WebTemplate"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateContentItemRelation", b => + { + b.HasOne("Raytha.Domain.Entities.ContentItem", "ContentItem") + .WithMany() + .HasForeignKey("ContentItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.WebTemplate", "WebTemplate") + .WithMany() + .HasForeignKey("WebTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ContentItem"); + + b.Navigation("WebTemplate"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateRevision", b => + { + b.HasOne("Raytha.Domain.Entities.User", "CreatorUser") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("Raytha.Domain.Entities.EmailTemplate", null) + .WithMany("Revisions") + .HasForeignKey("EmailTemplateId"); + + b.HasOne("Raytha.Domain.Entities.User", "LastModifierUser") + .WithMany() + .HasForeignKey("LastModifierUserId"); + + b.HasOne("Raytha.Domain.Entities.WebTemplate", "WebTemplate") + .WithMany("Revisions") + .HasForeignKey("WebTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatorUser"); + + b.Navigation("LastModifierUser"); + + b.Navigation("WebTemplate"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplateViewRelation", b => + { + b.HasOne("Raytha.Domain.Entities.View", "View") + .WithMany() + .HasForeignKey("ViewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.WebTemplate", "WebTemplate") + .WithMany() + .HasForeignKey("WebTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("View"); + + b.Navigation("WebTemplate"); + }); + + modelBuilder.Entity("RoleUser", b => + { + b.HasOne("Raytha.Domain.Entities.Role", null) + .WithMany() + .HasForeignKey("RolesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("UserUserGroup", b => + { + b.HasOne("Raytha.Domain.Entities.UserGroup", null) + .WithMany() + .HasForeignKey("UserGroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("UserView", b => + { + b.HasOne("Raytha.Domain.Entities.View", null) + .WithMany() + .HasForeignKey("FavoriteViewsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Raytha.Domain.Entities.User", null) + .WithMany() + .HasForeignKey("UserFavoritesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentItem", b => + { + b.Navigation("ContentItemRevisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.ContentType", b => + { + b.Navigation("ContentTypeFields"); + + b.Navigation("Views"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.EmailTemplate", b => + { + b.Navigation("Revisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.NavigationMenu", b => + { + b.Navigation("NavigationMenuItems"); + + b.Navigation("NavigationMenuRevisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.RaythaFunction", b => + { + b.Navigation("Revisions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Role", b => + { + b.Navigation("ContentTypeRolePermissions"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Route", b => + { + b.Navigation("ContentItem") + .IsRequired(); + + b.Navigation("View") + .IsRequired(); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.Theme", b => + { + b.Navigation("ThemeAccessToMediaItems"); + + b.Navigation("WebTemplates"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.User", b => + { + b.Navigation("ApiKeys"); + }); + + modelBuilder.Entity("Raytha.Domain.Entities.WebTemplate", b => + { + b.Navigation("Revisions"); + + b.Navigation("TemplateAccessToModelDefinitions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Raytha.Migrations.SqlServer/20241116192521_v1_4_0.cs b/src/Raytha.Migrations.SqlServer/20241116192521_v1_4_0.cs new file mode 100644 index 00000000..76e5934a --- /dev/null +++ b/src/Raytha.Migrations.SqlServer/20241116192521_v1_4_0.cs @@ -0,0 +1,221 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Raytha.Migrations.SqlServer +{ + /// <inheritdoc /> + public partial class v1_4_0 : Migration + { + /// <inheritdoc /> + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_WebTemplates_DeveloperName_ThemeId", + table: "WebTemplates"); + + migrationBuilder.DropIndex( + name: "IX_Users_EmailAddress", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_Users_SsoId_AuthenticationSchemeId", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_UserGroups_DeveloperName", + table: "UserGroups"); + + migrationBuilder.DropIndex( + name: "IX_Routes_Path", + table: "Routes"); + + migrationBuilder.DropIndex( + name: "IX_Roles_DeveloperName", + table: "Roles"); + + migrationBuilder.DropIndex( + name: "IX_JwtLogins_Jti", + table: "JwtLogins"); + + migrationBuilder.DropIndex( + name: "IX_AuthenticationSchemes_DeveloperName", + table: "AuthenticationSchemes"); + + migrationBuilder.AlterColumn<string>( + name: "DeveloperName", + table: "EmailTemplates", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.CreateIndex( + name: "IX_WebTemplates_DeveloperName_ThemeId", + table: "WebTemplates", + columns: new[] { "DeveloperName", "ThemeId" }, + unique: true, + filter: "[DeveloperName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Users_EmailAddress", + table: "Users", + column: "EmailAddress", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Users_SsoId_AuthenticationSchemeId", + table: "Users", + columns: new[] { "SsoId", "AuthenticationSchemeId" }, + unique: true, + filter: "[SsoId] IS NOT NULL AND [AuthenticationSchemeId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_UserGroups_DeveloperName", + table: "UserGroups", + column: "DeveloperName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Routes_Path", + table: "Routes", + column: "Path", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Roles_DeveloperName", + table: "Roles", + column: "DeveloperName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_JwtLogins_Jti", + table: "JwtLogins", + column: "Jti", + unique: true, + filter: "[Jti] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_EmailTemplates_DeveloperName", + table: "EmailTemplates", + column: "DeveloperName", + unique: true, + filter: "[DeveloperName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AuthenticationSchemes_DeveloperName", + table: "AuthenticationSchemes", + column: "DeveloperName", + unique: true, + filter: "[DeveloperName] IS NOT NULL"); + } + + /// <inheritdoc /> + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_WebTemplates_DeveloperName_ThemeId", + table: "WebTemplates"); + + migrationBuilder.DropIndex( + name: "IX_Users_EmailAddress", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_Users_SsoId_AuthenticationSchemeId", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_UserGroups_DeveloperName", + table: "UserGroups"); + + migrationBuilder.DropIndex( + name: "IX_Routes_Path", + table: "Routes"); + + migrationBuilder.DropIndex( + name: "IX_Roles_DeveloperName", + table: "Roles"); + + migrationBuilder.DropIndex( + name: "IX_JwtLogins_Jti", + table: "JwtLogins"); + + migrationBuilder.DropIndex( + name: "IX_EmailTemplates_DeveloperName", + table: "EmailTemplates"); + + migrationBuilder.DropIndex( + name: "IX_AuthenticationSchemes_DeveloperName", + table: "AuthenticationSchemes"); + + migrationBuilder.AlterColumn<string>( + name: "DeveloperName", + table: "EmailTemplates", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + + migrationBuilder.CreateIndex( + name: "IX_WebTemplates_DeveloperName_ThemeId", + table: "WebTemplates", + columns: new[] { "DeveloperName", "ThemeId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Users_EmailAddress", + table: "Users", + column: "EmailAddress", + unique: true) + .Annotation("SqlServer:Include", new[] { "Id", "FirstName", "LastName", "SsoId", "AuthenticationSchemeId" }); + + migrationBuilder.CreateIndex( + name: "IX_Users_SsoId_AuthenticationSchemeId", + table: "Users", + columns: new[] { "SsoId", "AuthenticationSchemeId" }, + unique: true, + filter: "[SsoId] IS NOT NULL AND [AuthenticationSchemeId] IS NOT NULL") + .Annotation("SqlServer:Include", new[] { "Id", "EmailAddress", "FirstName", "LastName" }); + + migrationBuilder.CreateIndex( + name: "IX_UserGroups_DeveloperName", + table: "UserGroups", + column: "DeveloperName", + unique: true) + .Annotation("SqlServer:Include", new[] { "Id", "Label" }); + + migrationBuilder.CreateIndex( + name: "IX_Routes_Path", + table: "Routes", + column: "Path", + unique: true) + .Annotation("SqlServer:Include", new[] { "Id", "ViewId", "ContentItemId" }); + + migrationBuilder.CreateIndex( + name: "IX_Roles_DeveloperName", + table: "Roles", + column: "DeveloperName", + unique: true) + .Annotation("SqlServer:Include", new[] { "Id", "Label" }); + + migrationBuilder.CreateIndex( + name: "IX_JwtLogins_Jti", + table: "JwtLogins", + column: "Jti", + unique: true, + filter: "[Jti] IS NOT NULL") + .Annotation("SqlServer:Include", new[] { "Id" }); + + migrationBuilder.CreateIndex( + name: "IX_AuthenticationSchemes_DeveloperName", + table: "AuthenticationSchemes", + column: "DeveloperName", + unique: true, + filter: "[DeveloperName] IS NOT NULL") + .Annotation("SqlServer:Include", new[] { "Id", "Label" }); + } + } +} diff --git a/src/Raytha.Migrations.SqlServer/RaythaDbContextModelSnapshot.cs b/src/Raytha.Migrations.SqlServer/RaythaDbContextModelSnapshot.cs index f0976a8d..f2c76447 100644 --- a/src/Raytha.Migrations.SqlServer/RaythaDbContextModelSnapshot.cs +++ b/src/Raytha.Migrations.SqlServer/RaythaDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -179,8 +179,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsUnique() .HasFilter("[DeveloperName] IS NOT NULL"); - SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("DeveloperName"), new[] { "Id", "Label" }); - b.HasIndex("LastModifierUserId"); b.ToTable("AuthenticationSchemes"); @@ -554,7 +552,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier"); b.Property<string>("DeveloperName") - .HasColumnType("nvarchar(max)"); + .HasColumnType("nvarchar(450)"); b.Property<bool>("IsBuiltInTemplate") .HasColumnType("bit"); @@ -572,6 +570,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("CreatorUserId"); + b.HasIndex("DeveloperName") + .IsUnique() + .HasFilter("[DeveloperName] IS NOT NULL"); + b.HasIndex("LastModifierUserId"); b.ToTable("EmailTemplates"); @@ -639,8 +641,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsUnique() .HasFilter("[Jti] IS NOT NULL"); - SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("Jti"), new[] { "Id" }); - b.ToTable("JwtLogins"); }); @@ -1025,8 +1025,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("DeveloperName") .IsUnique(); - SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("DeveloperName"), new[] { "Id", "Label" }); - b.HasIndex("LastModifierUserId"); b.ToTable("Roles"); @@ -1053,8 +1051,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Path") .IsUnique(); - SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("Path"), new[] { "Id", "ViewId", "ContentItemId" }); - b.ToTable("Routes"); }); @@ -1192,16 +1188,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("EmailAddress") .IsUnique(); - SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("EmailAddress"), new[] { "Id", "FirstName", "LastName", "SsoId", "AuthenticationSchemeId" }); - b.HasIndex("LastModifierUserId"); b.HasIndex("SsoId", "AuthenticationSchemeId") .IsUnique() .HasFilter("[SsoId] IS NOT NULL AND [AuthenticationSchemeId] IS NOT NULL"); - SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("SsoId", "AuthenticationSchemeId"), new[] { "Id", "EmailAddress", "FirstName", "LastName" }); - b.ToTable("Users"); }); @@ -1238,8 +1230,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("DeveloperName") .IsUnique(); - SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("DeveloperName"), new[] { "Id", "Label" }); - b.HasIndex("LastModifierUserId"); b.ToTable("UserGroups"); @@ -1409,7 +1399,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ThemeId"); b.HasIndex("DeveloperName", "ThemeId") - .IsUnique(); + .IsUnique() + .HasFilter("[DeveloperName] IS NOT NULL"); b.ToTable("WebTemplates"); });