1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
- #nullable disable
- namespace AvaloniaPractic.Migrations
- {
- /// <inheritdoc />
- public partial class UpdateUsersAndLoginedTables : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Roles",
- 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_Roles", x => x.Id);
- });
- migrationBuilder.CreateTable(
- name: "users",
- columns: table => new
- {
- id = table.Column<int>(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- username = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
- email = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
- createdat = table.Column<DateTime>(type: "timestamp without time zone", nullable: true, defaultValueSql: "CURRENT_TIMESTAMP")
- },
- constraints: table =>
- {
- table.PrimaryKey("users_pkey", x => x.id);
- });
- migrationBuilder.CreateTable(
- name: "Logins",
- columns: table => new
- {
- Id = table.Column<int>(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- Login = table.Column<string>(type: "text", nullable: false),
- Password = table.Column<string>(type: "text", nullable: false),
- RoleId = table.Column<int>(type: "integer", nullable: false),
- UserId = table.Column<int>(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Logins", x => x.Id);
- table.ForeignKey(
- name: "FK_Logins_Roles_RoleId",
- column: x => x.RoleId,
- principalTable: "Roles",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_Logins_users_UserId",
- column: x => x.UserId,
- principalTable: "users",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- });
- migrationBuilder.CreateIndex(
- name: "IX_Logins_RoleId",
- table: "Logins",
- column: "RoleId");
- migrationBuilder.CreateIndex(
- name: "IX_Logins_UserId",
- table: "Logins",
- column: "UserId");
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Logins");
- migrationBuilder.DropTable(
- name: "Roles");
- migrationBuilder.DropTable(
- name: "users");
- }
- }
- }
|