using System; using Microsoft.EntityFrameworkCore.Migrations; namespace EventBot.Migrations.Sqlite { public partial class InitialDatabase : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "GuildConfigs", columns: table => new { GuildId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Prefix = table.Column(nullable: true), EventRoleConfirmationChannelId = table.Column(nullable: false), ParticipantRoleId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_GuildConfigs", x => x.GuildId); }); migrationBuilder.CreateTable( name: "Events", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Title = table.Column(nullable: true), Description = table.Column(nullable: true), Active = table.Column(nullable: false), MessageId = table.Column(nullable: false), MessageChannelId = table.Column(nullable: false), Opened = table.Column(nullable: false), Type = table.Column(nullable: false), GuildId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Events", x => x.Id); table.ForeignKey( name: "FK_Events_GuildConfigs_GuildId", column: x => x.GuildId, principalTable: "GuildConfigs", principalColumn: "GuildId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EventRoles", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Title = table.Column(nullable: true), Description = table.Column(nullable: true), Emote = table.Column(nullable: true), MaxParticipants = table.Column(nullable: false), EventId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EventRoles", x => x.Id); table.ForeignKey( name: "FK_EventRoles_Events_EventId", column: x => x.EventId, principalTable: "Events", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EventParticipants", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), EventRoleId = table.Column(nullable: false), EventId = table.Column(nullable: false), UserId = table.Column(nullable: false), UserData = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_EventParticipants", x => x.Id); table.ForeignKey( name: "FK_EventParticipants_Events_EventId", column: x => x.EventId, principalTable: "Events", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EventParticipants_EventRoles_EventRoleId", column: x => x.EventRoleId, principalTable: "EventRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_EventParticipants_EventId", table: "EventParticipants", column: "EventId"); migrationBuilder.CreateIndex( name: "IX_EventParticipants_EventRoleId", table: "EventParticipants", column: "EventRoleId"); migrationBuilder.CreateIndex( name: "IX_EventRoles_EventId", table: "EventRoles", column: "EventId"); migrationBuilder.CreateIndex( name: "IX_Events_GuildId", table: "Events", column: "GuildId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "EventParticipants"); migrationBuilder.DropTable( name: "EventRoles"); migrationBuilder.DropTable( name: "Events"); migrationBuilder.DropTable( name: "GuildConfigs"); } } }