mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 13:40:13 +01:00
CreateDatabase
Nic nie działa bo wszystko jest inne XDD
This commit is contained in:
@@ -0,0 +1,279 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApp.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EventSkillsUsersOrganisations : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Place",
|
||||
table: "Events",
|
||||
newName: "Location");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Name",
|
||||
table: "Events",
|
||||
newName: "Title");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Date",
|
||||
table: "Events",
|
||||
newName: "EventDate");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Id",
|
||||
table: "Events",
|
||||
newName: "EventId");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "OrganisationId",
|
||||
table: "Events",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "AspNetUsers",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FirstName",
|
||||
table: "AspNetUsers",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsOrganisation",
|
||||
table: "AspNetUsers",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "LastName",
|
||||
table: "AspNetUsers",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EventRegistrations",
|
||||
columns: table => new
|
||||
{
|
||||
EventId = table.Column<int>(type: "integer", nullable: false),
|
||||
UserId = table.Column<string>(type: "text", nullable: false),
|
||||
RegisteredAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EventRegistrations", x => new { x.UserId, x.EventId });
|
||||
table.ForeignKey(
|
||||
name: "FK_EventRegistrations_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EventRegistrations_Events_EventId",
|
||||
column: x => x.EventId,
|
||||
principalTable: "Events",
|
||||
principalColumn: "EventId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Organisations",
|
||||
columns: table => new
|
||||
{
|
||||
OrganisationId = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
UserId = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
Website = table.Column<string>(type: "text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Organisations", x => x.OrganisationId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Organisations_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Skills",
|
||||
columns: table => new
|
||||
{
|
||||
SkillId = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Skills", x => x.SkillId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EventSkills",
|
||||
columns: table => new
|
||||
{
|
||||
EventId = table.Column<int>(type: "integer", nullable: false),
|
||||
SkillId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EventSkills", x => new { x.EventId, x.SkillId });
|
||||
table.ForeignKey(
|
||||
name: "FK_EventSkills_Events_EventId",
|
||||
column: x => x.EventId,
|
||||
principalTable: "Events",
|
||||
principalColumn: "EventId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EventSkills_Skills_SkillId",
|
||||
column: x => x.SkillId,
|
||||
principalTable: "Skills",
|
||||
principalColumn: "SkillId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "VolunteerSkills",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<string>(type: "text", nullable: false),
|
||||
SkillId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_VolunteerSkills", x => new { x.UserId, x.SkillId });
|
||||
table.ForeignKey(
|
||||
name: "FK_VolunteerSkills_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_VolunteerSkills_Skills_SkillId",
|
||||
column: x => x.SkillId,
|
||||
principalTable: "Skills",
|
||||
principalColumn: "SkillId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Events_OrganisationId",
|
||||
table: "Events",
|
||||
column: "OrganisationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EventRegistrations_EventId",
|
||||
table: "EventRegistrations",
|
||||
column: "EventId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EventSkills_SkillId",
|
||||
table: "EventSkills",
|
||||
column: "SkillId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Organisations_UserId",
|
||||
table: "Organisations",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VolunteerSkills_SkillId",
|
||||
table: "VolunteerSkills",
|
||||
column: "SkillId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Events_Organisations_OrganisationId",
|
||||
table: "Events",
|
||||
column: "OrganisationId",
|
||||
principalTable: "Organisations",
|
||||
principalColumn: "OrganisationId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Events_Organisations_OrganisationId",
|
||||
table: "Events");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EventRegistrations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EventSkills");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Organisations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "VolunteerSkills");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Skills");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Events_OrganisationId",
|
||||
table: "Events");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "OrganisationId",
|
||||
table: "Events");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FirstName",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsOrganisation",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastName",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Title",
|
||||
table: "Events",
|
||||
newName: "Name");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Location",
|
||||
table: "Events",
|
||||
newName: "Place");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "EventDate",
|
||||
table: "Events",
|
||||
newName: "Date");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "EventId",
|
||||
table: "Events",
|
||||
newName: "Id");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user