|
| 1 | +using Microsoft.EntityFrameworkCore.Migrations; |
| 2 | +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
| 3 | + |
| 4 | +namespace BaGet.Database.PostgreSql.Migrations |
| 5 | +{ |
| 6 | + public partial class FixVersionCaseSensitivity : Migration |
| 7 | + { |
| 8 | + protected override void Up(MigrationBuilder migrationBuilder) |
| 9 | + { |
| 10 | + // Make the "version" column case insensitive. |
| 11 | + migrationBuilder.AlterColumn<string>( |
| 12 | + name: "Version", |
| 13 | + table: "Packages", |
| 14 | + type: "citext", |
| 15 | + maxLength: 64, |
| 16 | + nullable: false, |
| 17 | + oldClrType: typeof(string), |
| 18 | + oldMaxLength: 64); |
| 19 | + |
| 20 | + // Npgsql 3.0 migration |
| 21 | + // See: http://www.npgsql.org/efcore/release-notes/3.0.html#default-value-generation-strategy-is-now-identity |
| 22 | + migrationBuilder.AlterColumn<int>( |
| 23 | + name: "Key", |
| 24 | + table: "TargetFrameworks", |
| 25 | + nullable: false, |
| 26 | + oldClrType: typeof(int)) |
| 27 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) |
| 28 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); |
| 29 | + |
| 30 | + migrationBuilder.AlterColumn<int>( |
| 31 | + name: "Key", |
| 32 | + table: "PackageTypes", |
| 33 | + nullable: false, |
| 34 | + oldClrType: typeof(int)) |
| 35 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) |
| 36 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); |
| 37 | + |
| 38 | + migrationBuilder.AlterColumn<int>( |
| 39 | + name: "Key", |
| 40 | + table: "Packages", |
| 41 | + nullable: false, |
| 42 | + oldClrType: typeof(int)) |
| 43 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) |
| 44 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); |
| 45 | + |
| 46 | + migrationBuilder.AlterColumn<int>( |
| 47 | + name: "Key", |
| 48 | + table: "PackageDependencies", |
| 49 | + nullable: false, |
| 50 | + oldClrType: typeof(int)) |
| 51 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) |
| 52 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); |
| 53 | + } |
| 54 | + |
| 55 | + protected override void Down(MigrationBuilder migrationBuilder) |
| 56 | + { |
| 57 | + migrationBuilder.AlterColumn<string>( |
| 58 | + name: "Version", |
| 59 | + table: "Packages", |
| 60 | + maxLength: 64, |
| 61 | + nullable: false, |
| 62 | + oldClrType: typeof(string), |
| 63 | + oldType: "citext", |
| 64 | + oldMaxLength: 64); |
| 65 | + |
| 66 | + migrationBuilder.AlterColumn<int>( |
| 67 | + name: "Key", |
| 68 | + table: "TargetFrameworks", |
| 69 | + nullable: false, |
| 70 | + oldClrType: typeof(int)) |
| 71 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) |
| 72 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); |
| 73 | + |
| 74 | + migrationBuilder.AlterColumn<int>( |
| 75 | + name: "Key", |
| 76 | + table: "PackageTypes", |
| 77 | + nullable: false, |
| 78 | + oldClrType: typeof(int)) |
| 79 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) |
| 80 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); |
| 81 | + |
| 82 | + migrationBuilder.AlterColumn<int>( |
| 83 | + name: "Key", |
| 84 | + table: "Packages", |
| 85 | + nullable: false, |
| 86 | + oldClrType: typeof(int)) |
| 87 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) |
| 88 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); |
| 89 | + |
| 90 | + migrationBuilder.AlterColumn<int>( |
| 91 | + name: "Key", |
| 92 | + table: "PackageDependencies", |
| 93 | + nullable: false, |
| 94 | + oldClrType: typeof(int)) |
| 95 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) |
| 96 | + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); |
| 97 | + } |
| 98 | + } |
| 99 | +} |
0 commit comments