using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Data.Migrations { /// public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", ",,"); migrationBuilder.CreateTable( name: "roles", columns: table => new { id = table.Column(type: "text", nullable: false), name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), normalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), concurrencyStamp = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("pK_roles", x => x.id); }); migrationBuilder.CreateTable( name: "service_alerts", columns: table => new { id = table.Column(type: "text", nullable: false), selectors = table.Column(type: "jsonb", nullable: false), cause = table.Column(type: "integer", nullable: false), effect = table.Column(type: "integer", nullable: false), header = table.Column(type: "jsonb", nullable: false), description = table.Column(type: "jsonb", nullable: false), info_urls = table.Column(type: "jsonb", nullable: false), inserted_date = table.Column(type: "timestamp with time zone", nullable: false), publish_date = table.Column(type: "timestamp with time zone", nullable: false), event_start_date = table.Column(type: "timestamp with time zone", nullable: false), event_end_date = table.Column(type: "timestamp with time zone", nullable: false), hidden_date = table.Column(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(type: "text", nullable: false), userName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), normalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), normalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), emailConfirmed = table.Column(type: "boolean", nullable: false), passwordHash = table.Column(type: "text", nullable: true), securityStamp = table.Column(type: "text", nullable: true), concurrencyStamp = table.Column(type: "text", nullable: true), phoneNumber = table.Column(type: "text", nullable: true), phoneNumberConfirmed = table.Column(type: "boolean", nullable: false), twoFactorEnabled = table.Column(type: "boolean", nullable: false), lockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), lockoutEnabled = table.Column(type: "boolean", nullable: false), accessFailedCount = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("pK_users", x => x.id); }); migrationBuilder.CreateTable( name: "role_claims", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), roleId = table.Column(type: "text", nullable: false), claimType = table.Column(type: "text", nullable: true), claimValue = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), userId = table.Column(type: "text", nullable: false), claimType = table.Column(type: "text", nullable: true), claimValue = table.Column(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(type: "text", nullable: false), providerKey = table.Column(type: "text", nullable: false), providerDisplayName = table.Column(type: "text", nullable: true), userId = table.Column(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(type: "text", nullable: false), roleId = table.Column(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(type: "text", nullable: false), loginProvider = table.Column(type: "text", nullable: false), name = table.Column(type: "text", nullable: false), value = table.Column(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); } /// 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"); } } }