aboutsummaryrefslogtreecommitdiff
path: root/src/Enmarcha.Backend/Data/Migrations/20260319113819_Initial.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Enmarcha.Backend/Data/Migrations/20260319113819_Initial.cs')
-rw-r--r--src/Enmarcha.Backend/Data/Migrations/20260319113819_Initial.cs251
1 files changed, 251 insertions, 0 deletions
diff --git a/src/Enmarcha.Backend/Data/Migrations/20260319113819_Initial.cs b/src/Enmarcha.Backend/Data/Migrations/20260319113819_Initial.cs
new file mode 100644
index 0000000..2548aa9
--- /dev/null
+++ b/src/Enmarcha.Backend/Data/Migrations/20260319113819_Initial.cs
@@ -0,0 +1,251 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Data.Migrations
+{
+ /// <inheritdoc />
+ public partial class Initial : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterDatabase()
+ .Annotation("Npgsql:PostgresExtension:postgis", ",,");
+
+ migrationBuilder.CreateTable(
+ name: "roles",
+ columns: table => new
+ {
+ id = table.Column<string>(type: "text", nullable: false),
+ name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ normalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ concurrencyStamp = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_roles", x => x.id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "service_alerts",
+ columns: table => new
+ {
+ id = table.Column<string>(type: "text", nullable: false),
+ selectors = table.Column<string>(type: "jsonb", nullable: false),
+ cause = table.Column<int>(type: "integer", nullable: false),
+ effect = table.Column<int>(type: "integer", nullable: false),
+ header = table.Column<string>(type: "jsonb", nullable: false),
+ description = table.Column<string>(type: "jsonb", nullable: false),
+ info_urls = table.Column<string>(type: "jsonb", nullable: false),
+ inserted_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+ publish_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+ event_start_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+ event_end_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+ hidden_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_service_alerts", x => x.id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "users",
+ columns: table => new
+ {
+ id = table.Column<string>(type: "text", nullable: false),
+ userName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ normalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ normalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ emailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
+ passwordHash = table.Column<string>(type: "text", nullable: true),
+ securityStamp = table.Column<string>(type: "text", nullable: true),
+ concurrencyStamp = table.Column<string>(type: "text", nullable: true),
+ phoneNumber = table.Column<string>(type: "text", nullable: true),
+ phoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
+ twoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
+ lockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
+ lockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
+ accessFailedCount = table.Column<int>(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_users", x => x.id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "role_claims",
+ columns: table => new
+ {
+ id = table.Column<int>(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ roleId = table.Column<string>(type: "text", nullable: false),
+ claimType = table.Column<string>(type: "text", nullable: true),
+ claimValue = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_role_claims", x => x.id);
+ table.ForeignKey(
+ name: "fK_role_claims_roles_roleId",
+ column: x => x.roleId,
+ principalTable: "roles",
+ principalColumn: "id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "user_claims",
+ columns: table => new
+ {
+ id = table.Column<int>(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ userId = table.Column<string>(type: "text", nullable: false),
+ claimType = table.Column<string>(type: "text", nullable: true),
+ claimValue = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_user_claims", x => x.id);
+ table.ForeignKey(
+ name: "fK_user_claims_users_userId",
+ column: x => x.userId,
+ principalTable: "users",
+ principalColumn: "id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "user_logins",
+ columns: table => new
+ {
+ loginProvider = table.Column<string>(type: "text", nullable: false),
+ providerKey = table.Column<string>(type: "text", nullable: false),
+ providerDisplayName = table.Column<string>(type: "text", nullable: true),
+ userId = table.Column<string>(type: "text", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_user_logins", x => new { x.loginProvider, x.providerKey });
+ table.ForeignKey(
+ name: "fK_user_logins_users_userId",
+ column: x => x.userId,
+ principalTable: "users",
+ principalColumn: "id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "user_roles",
+ columns: table => new
+ {
+ userId = table.Column<string>(type: "text", nullable: false),
+ roleId = table.Column<string>(type: "text", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_user_roles", x => new { x.userId, x.roleId });
+ table.ForeignKey(
+ name: "fK_user_roles_roles_roleId",
+ column: x => x.roleId,
+ principalTable: "roles",
+ principalColumn: "id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "fK_user_roles_users_userId",
+ column: x => x.userId,
+ principalTable: "users",
+ principalColumn: "id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "user_tokens",
+ columns: table => new
+ {
+ userId = table.Column<string>(type: "text", nullable: false),
+ loginProvider = table.Column<string>(type: "text", nullable: false),
+ name = table.Column<string>(type: "text", nullable: false),
+ value = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pK_user_tokens", x => new { x.userId, x.loginProvider, x.name });
+ table.ForeignKey(
+ name: "fK_user_tokens_users_userId",
+ column: x => x.userId,
+ principalTable: "users",
+ principalColumn: "id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "iX_role_claims_roleId",
+ table: "role_claims",
+ column: "roleId");
+
+ migrationBuilder.CreateIndex(
+ name: "RoleNameIndex",
+ table: "roles",
+ column: "normalizedName",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "iX_user_claims_userId",
+ table: "user_claims",
+ column: "userId");
+
+ migrationBuilder.CreateIndex(
+ name: "iX_user_logins_userId",
+ table: "user_logins",
+ column: "userId");
+
+ migrationBuilder.CreateIndex(
+ name: "iX_user_roles_roleId",
+ table: "user_roles",
+ column: "roleId");
+
+ migrationBuilder.CreateIndex(
+ name: "EmailIndex",
+ table: "users",
+ column: "normalizedEmail");
+
+ migrationBuilder.CreateIndex(
+ name: "UserNameIndex",
+ table: "users",
+ column: "normalizedUserName",
+ unique: true);
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "role_claims");
+
+ migrationBuilder.DropTable(
+ name: "service_alerts");
+
+ migrationBuilder.DropTable(
+ name: "user_claims");
+
+ migrationBuilder.DropTable(
+ name: "user_logins");
+
+ migrationBuilder.DropTable(
+ name: "user_roles");
+
+ migrationBuilder.DropTable(
+ name: "user_tokens");
+
+ migrationBuilder.DropTable(
+ name: "roles");
+
+ migrationBuilder.DropTable(
+ name: "users");
+ }
+ }
+}