143 lines
6.4 KiB
C#
143 lines
6.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace FinlyticBackend.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "service_configurations",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
service_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
config_key = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
config_value = table.Column<string>(type: "text", nullable: false),
|
|
data_type = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
description = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
updated_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_service_configurations", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "users",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
email = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: false),
|
|
password_hash = table.Column<string>(type: "text", nullable: false),
|
|
full_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
role = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
|
created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
last_login_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
theme_preference = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_users", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "user_device_tokens",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
fcm_token = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false),
|
|
device_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
registered_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
last_used_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_user_device_tokens", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_user_device_tokens_users_user_id",
|
|
column: x => x.user_id,
|
|
principalTable: "users",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "user_favorite_assets",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
isin = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_user_favorite_assets", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_user_favorite_assets_users_user_id",
|
|
column: x => x.user_id,
|
|
principalTable: "users",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_service_configurations_service_name_config_key",
|
|
table: "service_configurations",
|
|
columns: new[] { "service_name", "config_key" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_user_device_tokens_fcm_token",
|
|
table: "user_device_tokens",
|
|
column: "fcm_token");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_user_device_tokens_user_id",
|
|
table: "user_device_tokens",
|
|
column: "user_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_user_favorite_assets_user_id_isin",
|
|
table: "user_favorite_assets",
|
|
columns: new[] { "user_id", "isin" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_users_email",
|
|
table: "users",
|
|
column: "email",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_users_role",
|
|
table: "users",
|
|
column: "role");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "service_configurations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "user_device_tokens");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "user_favorite_assets");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "users");
|
|
}
|
|
}
|
|
}
|