using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace back.Migrations { /// public partial class InitialSetup : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "__EFMigrationsLock", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false), Timestamp = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK___EFMigrationsLock", x => x.Id); }); migrationBuilder.CreateTable( name: "Events", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Title = table.Column(type: "TEXT", maxLength: 50, nullable: false), Description = table.Column(type: "TEXT", maxLength: 500, nullable: true), Date = table.Column(type: "TEXT", nullable: true), Location = table.Column(type: "TEXT", nullable: true), CreatedAt = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: false), CreatedBy = table.Column(type: "TEXT", nullable: true), UpdatedBy = table.Column(type: "TEXT", nullable: true), IsDeleted = table.Column(type: "INTEGER", nullable: false), DeletedAt = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Events", x => x.Id); }); migrationBuilder.CreateTable( name: "Permissions", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", maxLength: 100, nullable: false), Description = table.Column(type: "TEXT", maxLength: 255, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Permissions", x => x.Id); }); migrationBuilder.CreateTable( name: "Rankings", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), TotalVotes = table.Column(type: "INTEGER", nullable: false), UpVotes = table.Column(type: "INTEGER", nullable: false), DownVotes = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Rankings", x => x.Id); }); migrationBuilder.CreateTable( name: "Roles", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", maxLength: 100, nullable: false), Description = table.Column(type: "TEXT", maxLength: 250, nullable: true), BaseRoleModelId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); table.ForeignKey( name: "FK_Roles_Roles_BaseRoleModelId", column: x => x.BaseRoleModelId, principalTable: "Roles", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "SocialMedia", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Facebook = table.Column(type: "TEXT", nullable: true), Instagram = table.Column(type: "TEXT", nullable: true), Twitter = table.Column(type: "TEXT", nullable: true), BlueSky = table.Column(type: "TEXT", nullable: true), Tiktok = table.Column(type: "TEXT", nullable: true), Linkedin = table.Column(type: "TEXT", nullable: true), Pinterest = table.Column(type: "TEXT", nullable: true), Discord = table.Column(type: "TEXT", nullable: true), Reddit = table.Column(type: "TEXT", nullable: true), Other = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_SocialMedia", x => x.Id); }); migrationBuilder.CreateTable( name: "Tags", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", maxLength: 25, nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tags", x => x.Id); }); migrationBuilder.CreateTable( name: "RolePermissions", columns: table => new { RoleId = table.Column(type: "TEXT", nullable: false), PermissionId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_RolePermissions", x => new { x.RoleId, x.PermissionId }); table.ForeignKey( name: "FK_RolePermissions_Permissions_PermissionId", column: x => x.PermissionId, principalTable: "Permissions", principalColumn: "Id"); table.ForeignKey( name: "FK_RolePermissions_Roles_RoleId", column: x => x.RoleId, principalTable: "Roles", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Persons", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", maxLength: 100, nullable: false), ProfilePicture = table.Column(type: "TEXT", nullable: true), Avatar = table.Column(type: "TEXT", nullable: true), SocialMediaId = table.Column(type: "TEXT", nullable: true), Bio = table.Column(type: "TEXT", maxLength: 250, nullable: true), CreatedAt = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: true), IsDeleted = table.Column(type: "INTEGER", nullable: false), DeletedAt = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Persons", x => x.Id); table.ForeignKey( name: "FK_Persons_SocialMedia_SocialMediaId", column: x => x.SocialMediaId, principalTable: "SocialMedia", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "EventTags", columns: table => new { EventId = table.Column(type: "TEXT", nullable: false), TagId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_EventTags", x => new { x.EventId, x.TagId }); table.ForeignKey( name: "FK_EventTags_Events_EventId", column: x => x.EventId, principalTable: "Events", principalColumn: "Id"); table.ForeignKey( name: "FK_EventTags_Tags_TagId", column: x => x.TagId, principalTable: "Tags", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Photos", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Title = table.Column(type: "TEXT", maxLength: 100, nullable: false), Description = table.Column(type: "TEXT", maxLength: 500, nullable: true), Extension = table.Column(type: "TEXT", nullable: true), LowResUrl = table.Column(type: "TEXT", nullable: true), MidResUrl = table.Column(type: "TEXT", nullable: true), HighResUrl = table.Column(type: "TEXT", nullable: true), CreatedAt = table.Column(type: "TEXT", nullable: true), UpdatedAt = table.Column(type: "TEXT", nullable: true), CreatedBy = table.Column(type: "TEXT", nullable: false), UpdatedBy = table.Column(type: "TEXT", nullable: true), EventId = table.Column(type: "TEXT", nullable: true), RankingId = table.Column(type: "TEXT", nullable: true), IsFavorite = table.Column(type: "INTEGER", nullable: true, defaultValue: 0), IsPublic = table.Column(type: "INTEGER", nullable: true, defaultValue: 1), IsArchived = table.Column(type: "INTEGER", nullable: true, defaultValue: 0) }, constraints: table => { table.PrimaryKey("PK_Photos", x => x.Id); table.ForeignKey( name: "FK_Photos_Events_EventId", column: x => x.EventId, principalTable: "Events", principalColumn: "Id"); table.ForeignKey( name: "FK_Photos_Persons_CreatedBy", column: x => x.CreatedBy, principalTable: "Persons", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Email = table.Column(type: "TEXT", nullable: false), Password = table.Column(type: "TEXT", nullable: false), Salt = table.Column(type: "TEXT", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); table.ForeignKey( name: "FK_Users_Persons_Id", column: x => x.Id, principalTable: "Persons", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "PhotoPersons", columns: table => new { PhotoId = table.Column(type: "TEXT", nullable: false), PersonId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PhotoPersons", x => new { x.PhotoId, x.PersonId }); table.ForeignKey( name: "FK_PhotoPersons_Persons_PersonId", column: x => x.PersonId, principalTable: "Persons", principalColumn: "Id"); table.ForeignKey( name: "FK_PhotoPersons_Photos_PhotoId", column: x => x.PhotoId, principalTable: "Photos", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "PhotoTags", columns: table => new { PhotoId = table.Column(type: "TEXT", nullable: false), TagId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PhotoTags", x => new { x.PhotoId, x.TagId }); table.ForeignKey( name: "FK_PhotoTags_Photos_PhotoId", column: x => x.PhotoId, principalTable: "Photos", principalColumn: "Id"); table.ForeignKey( name: "FK_PhotoTags_Tags_TagId", column: x => x.TagId, principalTable: "Tags", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Galleries", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Title = table.Column(type: "TEXT", maxLength: 100, nullable: true), Description = table.Column(type: "TEXT", maxLength: 500, nullable: true), CreatedAt = table.Column(type: "TEXT", nullable: true), UpdatedAt = table.Column(type: "TEXT", nullable: true), CreatedBy = table.Column(type: "TEXT", nullable: false), IsPublic = table.Column(type: "INTEGER", nullable: true, defaultValue: 1), IsArchived = table.Column(type: "INTEGER", nullable: true, defaultValue: 0), IsFavorite = table.Column(type: "INTEGER", nullable: true, defaultValue: 0), IsDeleted = table.Column(type: "INTEGER", nullable: false), DeletedAt = table.Column(type: "TEXT", nullable: true), EventId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Galleries", x => x.Id); table.ForeignKey( name: "FK_Galleries_Events_EventId", column: x => x.EventId, principalTable: "Events", principalColumn: "Id"); table.ForeignKey( name: "FK_Galleries_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "PhotoUserBuyers", columns: table => new { PhotoId = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PhotoUserBuyers", x => new { x.PhotoId, x.UserId }); table.ForeignKey( name: "FK_PhotoUserBuyers_Photos_PhotoId", column: x => x.PhotoId, principalTable: "Photos", principalColumn: "Id"); table.ForeignKey( name: "FK_PhotoUserBuyers_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "UserRoles", columns: table => new { UserId = table.Column(type: "TEXT", nullable: false), RoleId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_UserRoles_Roles_RoleId", column: x => x.RoleId, principalTable: "Roles", principalColumn: "Id"); table.ForeignKey( name: "FK_UserRoles_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "GalleryPhotos", columns: table => new { GalleryId = table.Column(type: "TEXT", nullable: false), PhotoId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_GalleryPhotos", x => new { x.GalleryId, x.PhotoId }); table.ForeignKey( name: "FK_GalleryPhotos_Galleries_GalleryId", column: x => x.GalleryId, principalTable: "Galleries", principalColumn: "Id"); table.ForeignKey( name: "FK_GalleryPhotos_Photos_PhotoId", column: x => x.PhotoId, principalTable: "Photos", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "GalleryTags", columns: table => new { GalleryId = table.Column(type: "TEXT", nullable: false), TagId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_GalleryTags", x => new { x.GalleryId, x.TagId }); table.ForeignKey( name: "FK_GalleryTags_Galleries_GalleryId", column: x => x.GalleryId, principalTable: "Galleries", principalColumn: "Id"); table.ForeignKey( name: "FK_GalleryTags_Tags_TagId", column: x => x.TagId, principalTable: "Tags", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "GalleryUserViewers", columns: table => new { GalleryId = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_GalleryUserViewers", x => new { x.GalleryId, x.UserId }); table.ForeignKey( name: "FK_GalleryUserViewers_Galleries_GalleryId", column: x => x.GalleryId, principalTable: "Galleries", principalColumn: "Id"); table.ForeignKey( name: "FK_GalleryUserViewers_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_EventTags_TagId", table: "EventTags", column: "TagId"); migrationBuilder.CreateIndex( name: "IX_Galleries_CreatedBy", table: "Galleries", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Galleries_EventId", table: "Galleries", column: "EventId"); migrationBuilder.CreateIndex( name: "IX_GalleryPhotos_PhotoId", table: "GalleryPhotos", column: "PhotoId"); migrationBuilder.CreateIndex( name: "IX_GalleryTags_TagId", table: "GalleryTags", column: "TagId"); migrationBuilder.CreateIndex( name: "IX_GalleryUserViewers_UserId", table: "GalleryUserViewers", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Persons_SocialMediaId", table: "Persons", column: "SocialMediaId"); migrationBuilder.CreateIndex( name: "IX_PhotoPersons_PersonId", table: "PhotoPersons", column: "PersonId"); migrationBuilder.CreateIndex( name: "IX_Photos_CreatedBy", table: "Photos", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Photos_EventId", table: "Photos", column: "EventId"); migrationBuilder.CreateIndex( name: "IX_PhotoTags_TagId", table: "PhotoTags", column: "TagId"); migrationBuilder.CreateIndex( name: "IX_PhotoUserBuyers_UserId", table: "PhotoUserBuyers", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_RolePermissions_PermissionId", table: "RolePermissions", column: "PermissionId"); migrationBuilder.CreateIndex( name: "IX_Roles_BaseRoleModelId", table: "Roles", column: "BaseRoleModelId"); migrationBuilder.CreateIndex( name: "IX_Tags_Name", table: "Tags", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_UserRoles_RoleId", table: "UserRoles", column: "RoleId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "__EFMigrationsLock"); migrationBuilder.DropTable( name: "EventTags"); migrationBuilder.DropTable( name: "GalleryPhotos"); migrationBuilder.DropTable( name: "GalleryTags"); migrationBuilder.DropTable( name: "GalleryUserViewers"); migrationBuilder.DropTable( name: "PhotoPersons"); migrationBuilder.DropTable( name: "PhotoTags"); migrationBuilder.DropTable( name: "PhotoUserBuyers"); migrationBuilder.DropTable( name: "Rankings"); migrationBuilder.DropTable( name: "RolePermissions"); migrationBuilder.DropTable( name: "UserRoles"); migrationBuilder.DropTable( name: "Galleries"); migrationBuilder.DropTable( name: "Tags"); migrationBuilder.DropTable( name: "Photos"); migrationBuilder.DropTable( name: "Permissions"); migrationBuilder.DropTable( name: "Roles"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Events"); migrationBuilder.DropTable( name: "Persons"); migrationBuilder.DropTable( name: "SocialMedia"); } } }