| | | 1 | | |
| | | 2 | | using Microsoft.EntityFrameworkCore.Migrations; |
| | | 3 | | |
| | | 4 | | #nullable disable |
| | | 5 | | |
| | | 6 | | namespace Elsa.Persistence.EFCore.PostgreSql.Migrations.Identity |
| | | 7 | | { |
| | | 8 | | /// <inheritdoc /> |
| | | 9 | | public partial class Initial : Migration |
| | | 10 | | { |
| | | 11 | | private readonly IElsaDbContextSchema _schema; |
| | 2 | 12 | | public Initial(IElsaDbContextSchema schema) |
| | | 13 | | { |
| | 2 | 14 | | _schema = schema ?? throw new ArgumentNullException(nameof(schema)); |
| | 2 | 15 | | } |
| | | 16 | | /// <inheritdoc /> |
| | | 17 | | protected override void Up(MigrationBuilder migrationBuilder) |
| | | 18 | | { |
| | 2 | 19 | | migrationBuilder.EnsureSchema( |
| | 2 | 20 | | name: _schema.Schema); |
| | | 21 | | |
| | 2 | 22 | | migrationBuilder.CreateTable( |
| | 2 | 23 | | name: "Applications", |
| | 2 | 24 | | schema: _schema.Schema, |
| | 2 | 25 | | columns: table => new |
| | 2 | 26 | | { |
| | 2 | 27 | | Id = table.Column<string>(type: "text", nullable: false), |
| | 2 | 28 | | ClientId = table.Column<string>(type: "text", nullable: false), |
| | 2 | 29 | | HashedClientSecret = table.Column<string>(type: "text", nullable: false), |
| | 2 | 30 | | HashedClientSecretSalt = table.Column<string>(type: "text", nullable: false), |
| | 2 | 31 | | Name = table.Column<string>(type: "text", nullable: false), |
| | 2 | 32 | | HashedApiKey = table.Column<string>(type: "text", nullable: false), |
| | 2 | 33 | | HashedApiKeySalt = table.Column<string>(type: "text", nullable: false), |
| | 2 | 34 | | Roles = table.Column<string>(type: "text", nullable: false) |
| | 2 | 35 | | }, |
| | 2 | 36 | | constraints: table => |
| | 2 | 37 | | { |
| | 2 | 38 | | table.PrimaryKey("PK_Applications", x => x.Id); |
| | 4 | 39 | | }); |
| | | 40 | | |
| | 2 | 41 | | migrationBuilder.CreateTable( |
| | 2 | 42 | | name: "Roles", |
| | 2 | 43 | | schema: _schema.Schema, |
| | 2 | 44 | | columns: table => new |
| | 2 | 45 | | { |
| | 2 | 46 | | Id = table.Column<string>(type: "text", nullable: false), |
| | 2 | 47 | | Name = table.Column<string>(type: "text", nullable: false), |
| | 2 | 48 | | Permissions = table.Column<string>(type: "text", nullable: false) |
| | 2 | 49 | | }, |
| | 2 | 50 | | constraints: table => |
| | 2 | 51 | | { |
| | 2 | 52 | | table.PrimaryKey("PK_Roles", x => x.Id); |
| | 4 | 53 | | }); |
| | | 54 | | |
| | 2 | 55 | | migrationBuilder.CreateTable( |
| | 2 | 56 | | name: "Users", |
| | 2 | 57 | | schema: _schema.Schema, |
| | 2 | 58 | | columns: table => new |
| | 2 | 59 | | { |
| | 2 | 60 | | Id = table.Column<string>(type: "text", nullable: false), |
| | 2 | 61 | | Name = table.Column<string>(type: "text", nullable: false), |
| | 2 | 62 | | HashedPassword = table.Column<string>(type: "text", nullable: false), |
| | 2 | 63 | | HashedPasswordSalt = table.Column<string>(type: "text", nullable: false), |
| | 2 | 64 | | Roles = table.Column<string>(type: "text", nullable: false) |
| | 2 | 65 | | }, |
| | 2 | 66 | | constraints: table => |
| | 2 | 67 | | { |
| | 2 | 68 | | table.PrimaryKey("PK_Users", x => x.Id); |
| | 4 | 69 | | }); |
| | | 70 | | |
| | 2 | 71 | | migrationBuilder.CreateIndex( |
| | 2 | 72 | | name: "IX_Application_ClientId", |
| | 2 | 73 | | schema: _schema.Schema, |
| | 2 | 74 | | table: "Applications", |
| | 2 | 75 | | column: "ClientId", |
| | 2 | 76 | | unique: true); |
| | | 77 | | |
| | 2 | 78 | | migrationBuilder.CreateIndex( |
| | 2 | 79 | | name: "IX_Application_Name", |
| | 2 | 80 | | schema: _schema.Schema, |
| | 2 | 81 | | table: "Applications", |
| | 2 | 82 | | column: "Name", |
| | 2 | 83 | | unique: true); |
| | | 84 | | |
| | 2 | 85 | | migrationBuilder.CreateIndex( |
| | 2 | 86 | | name: "IX_Role_Name", |
| | 2 | 87 | | schema: _schema.Schema, |
| | 2 | 88 | | table: "Roles", |
| | 2 | 89 | | column: "Name", |
| | 2 | 90 | | unique: true); |
| | | 91 | | |
| | 2 | 92 | | migrationBuilder.CreateIndex( |
| | 2 | 93 | | name: "IX_User_Name", |
| | 2 | 94 | | schema: _schema.Schema, |
| | 2 | 95 | | table: "Users", |
| | 2 | 96 | | column: "Name", |
| | 2 | 97 | | unique: true); |
| | 2 | 98 | | } |
| | | 99 | | |
| | | 100 | | /// <inheritdoc /> |
| | | 101 | | protected override void Down(MigrationBuilder migrationBuilder) |
| | | 102 | | { |
| | 0 | 103 | | migrationBuilder.DropTable( |
| | 0 | 104 | | name: "Applications", |
| | 0 | 105 | | schema: _schema.Schema); |
| | | 106 | | |
| | 0 | 107 | | migrationBuilder.DropTable( |
| | 0 | 108 | | name: "Roles", |
| | 0 | 109 | | schema: _schema.Schema); |
| | | 110 | | |
| | 0 | 111 | | migrationBuilder.DropTable( |
| | 0 | 112 | | name: "Users", |
| | 0 | 113 | | schema: _schema.Schema); |
| | 0 | 114 | | } |
| | | 115 | | } |
| | | 116 | | } |