system-praktyk-api/src/InternshipSystem.Repository/Migrations/20201015165238_init.cs
2020-10-15 18:56:27 +02:00

470 lines
21 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
public partial class init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "companies",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
nip = table.Column<string>(nullable: true),
name = table.Column<string>(nullable: true),
provider = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_companies", x => x.id);
});
migrationBuilder.CreateTable(
name: "course",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_course", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_subject",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_subject", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_types",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
label = table.Column<string>(nullable: true),
label_eng = table.Column<string>(nullable: true),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_types", x => x.id);
});
migrationBuilder.CreateTable(
name: "report",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
state = table.Column<int>(nullable: false),
range = table.Column<int>(nullable: false),
site_address = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_report", x => x.id);
});
migrationBuilder.CreateTable(
name: "static_pages",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
access_name = table.Column<string>(nullable: true),
title = table.Column<string>(nullable: true),
title_eng = table.Column<string>(nullable: true),
content = table.Column<string>(nullable: true),
content_eng = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_static_pages", x => x.id);
});
migrationBuilder.CreateTable(
name: "students",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
album_number = table.Column<int>(nullable: false),
first_name = table.Column<string>(nullable: true),
last_name = table.Column<string>(nullable: true),
email = table.Column<string>(nullable: true),
course = table.Column<string>(nullable: true),
semester = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_students", x => x.id);
});
migrationBuilder.CreateTable(
name: "branch_office",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
street = table.Column<string>(nullable: true),
building = table.Column<string>(nullable: true),
city = table.Column<string>(nullable: true),
postal_code = table.Column<string>(nullable: true),
country = table.Column<string>(nullable: true),
provider = table.Column<long>(nullable: false),
company_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_branch_office", x => x.id);
table.ForeignKey(
name: "fk_branch_office_companies_company_id",
column: x => x.company_id,
principalTable: "companies",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "editions",
columns: table => new
{
id = table.Column<Guid>(nullable: false),
edition_start = table.Column<DateTime>(nullable: false),
edition_finish = table.Column<DateTime>(nullable: false),
reporting_start = table.Column<DateTime>(nullable: false),
course_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_editions", x => x.id);
table.ForeignKey(
name: "fk_editions_course_course_id",
column: x => x.course_id,
principalTable: "course",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "internship_registration",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
company_id = table.Column<long>(nullable: true),
branch_address_id = table.Column<long>(nullable: true),
start = table.Column<DateTime>(nullable: false),
end = table.Column<DateTime>(nullable: false),
first_name = table.Column<string>(nullable: true),
last_name = table.Column<string>(nullable: true),
email = table.Column<string>(nullable: true),
phone_number = table.Column<string>(nullable: true),
type_id = table.Column<long>(nullable: true),
declared_hours = table.Column<int>(nullable: false),
state = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_registration", x => x.id);
table.ForeignKey(
name: "fk_internship_registration_branch_office_branch_address_id",
column: x => x.branch_address_id,
principalTable: "branch_office",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_registration_companies_company_id",
column: x => x.company_id,
principalTable: "companies",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_registration_internship_types_type_id",
column: x => x.type_id,
principalTable: "internship_types",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "edition_internship_type",
columns: table => new
{
edition_id = table.Column<Guid>(nullable: false),
internship_type_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_edition_internship_type", x => new { x.edition_id, x.internship_type_id });
table.ForeignKey(
name: "fk_edition_internship_type_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_edition_internship_type_internship_types_internship_type_id",
column: x => x.internship_type_id,
principalTable: "internship_types",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "edition_subject",
columns: table => new
{
edition_id = table.Column<Guid>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_edition_subject", x => new { x.edition_id, x.internship_subject_id });
table.ForeignKey(
name: "fk_edition_subject_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_edition_subject_internship_subject_internship_subject_id",
column: x => x.internship_subject_id,
principalTable: "internship_subject",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "internship",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
student_id = table.Column<long>(nullable: true),
internship_registration_id = table.Column<long>(nullable: true),
report_id = table.Column<long>(nullable: true),
edition_id = table.Column<Guid>(nullable: true),
grade = table.Column<float>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internship", x => x.id);
table.ForeignKey(
name: "fk_internship_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_internship_registration_internship_registration_",
column: x => x.internship_registration_id,
principalTable: "internship_registration",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_report_report_id",
column: x => x.report_id,
principalTable: "report",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_students_student_id",
column: x => x.student_id,
principalTable: "students",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "program_subject",
columns: table => new
{
internship_registration_id = table.Column<long>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_program_subject", x => new { x.internship_registration_id, x.internship_subject_id });
table.ForeignKey(
name: "fk_program_subject_internship_registration_internship_registrat",
column: x => x.internship_registration_id,
principalTable: "internship_registration",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_program_subject_internship_subject_internship_subject_id",
column: x => x.internship_subject_id,
principalTable: "internship_subject",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "document",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
description = table.Column<string>(nullable: true),
scan = table.Column<byte[]>(nullable: true),
type = table.Column<int>(nullable: false),
state = table.Column<int>(nullable: false),
rejection_reason = table.Column<string>(nullable: true),
internship_id = table.Column<long>(nullable: true),
internship_id1 = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_document", x => x.id);
table.ForeignKey(
name: "fk_document_internship_internship_id",
column: x => x.internship_id,
principalTable: "internship",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_document_internship_internship_id1",
column: x => x.internship_id1,
principalTable: "internship",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "ix_branch_office_company_id",
table: "branch_office",
column: "company_id");
migrationBuilder.CreateIndex(
name: "ix_document_internship_id",
table: "document",
column: "internship_id");
migrationBuilder.CreateIndex(
name: "ix_document_internship_id1",
table: "document",
column: "internship_id1");
migrationBuilder.CreateIndex(
name: "ix_edition_internship_type_internship_type_id",
table: "edition_internship_type",
column: "internship_type_id");
migrationBuilder.CreateIndex(
name: "ix_edition_subject_internship_subject_id",
table: "edition_subject",
column: "internship_subject_id");
migrationBuilder.CreateIndex(
name: "ix_editions_course_id",
table: "editions",
column: "course_id");
migrationBuilder.CreateIndex(
name: "ix_internship_edition_id",
table: "internship",
column: "edition_id");
migrationBuilder.CreateIndex(
name: "ix_internship_internship_registration_id",
table: "internship",
column: "internship_registration_id");
migrationBuilder.CreateIndex(
name: "ix_internship_report_id",
table: "internship",
column: "report_id");
migrationBuilder.CreateIndex(
name: "ix_internship_student_id",
table: "internship",
column: "student_id");
migrationBuilder.CreateIndex(
name: "ix_internship_registration_branch_address_id",
table: "internship_registration",
column: "branch_address_id");
migrationBuilder.CreateIndex(
name: "ix_internship_registration_company_id",
table: "internship_registration",
column: "company_id");
migrationBuilder.CreateIndex(
name: "ix_internship_registration_type_id",
table: "internship_registration",
column: "type_id");
migrationBuilder.CreateIndex(
name: "ix_program_subject_internship_subject_id",
table: "program_subject",
column: "internship_subject_id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "document");
migrationBuilder.DropTable(
name: "edition_internship_type");
migrationBuilder.DropTable(
name: "edition_subject");
migrationBuilder.DropTable(
name: "program_subject");
migrationBuilder.DropTable(
name: "static_pages");
migrationBuilder.DropTable(
name: "internship");
migrationBuilder.DropTable(
name: "internship_subject");
migrationBuilder.DropTable(
name: "editions");
migrationBuilder.DropTable(
name: "internship_registration");
migrationBuilder.DropTable(
name: "report");
migrationBuilder.DropTable(
name: "students");
migrationBuilder.DropTable(
name: "course");
migrationBuilder.DropTable(
name: "branch_office");
migrationBuilder.DropTable(
name: "internship_types");
migrationBuilder.DropTable(
name: "companies");
}
}
}