64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace data.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class InitialCreate : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "groups",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = 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_groups", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "users",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_users", x => x.Guid);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_users_groups_GroupId",
|
|||
|
column: x => x.GroupId,
|
|||
|
principalTable: "groups",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_users_GroupId",
|
|||
|
table: "users",
|
|||
|
column: "GroupId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "users");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "groups");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|