diff options
Diffstat (limited to 'api/WhatApi/Migrations/20251026215643_Initial.cs')
| -rw-r--r-- | api/WhatApi/Migrations/20251026215643_Initial.cs | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/api/WhatApi/Migrations/20251026215643_Initial.cs b/api/WhatApi/Migrations/20251026215643_Initial.cs new file mode 100644 index 0000000..b8f0444 --- /dev/null +++ b/api/WhatApi/Migrations/20251026215643_Initial.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Net; +using Microsoft.EntityFrameworkCore.Migrations; +using NetTopologySuite.Geometries; + +#nullable disable + +namespace WhatApi.Migrations +{ + /// <inheritdoc /> + public partial class Initial : Migration + { + /// <inheritdoc /> + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("Npgsql:PostgresExtension:postgis", ",,"); + + migrationBuilder.CreateTable( + name: "audit_trails", + columns: table => new + { + Id = table.Column<Guid>(type: "uuid", nullable: false), + UserId = table.Column<Guid>(type: "uuid", nullable: true), + EntityName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), + PrimaryKey = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true), + TrailType = table.Column<string>(type: "text", nullable: false), + DateUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), + OldValues = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: false), + NewValues = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: false), + ChangedColumns = table.Column<List<string>>(type: "jsonb", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_audit_trails", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "content", + columns: table => new + { + Id = table.Column<Guid>(type: "uuid", nullable: false), + Mime = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), + BlobId = table.Column<Guid>(type: "uuid", nullable: false), + Ip = table.Column<IPAddress>(type: "inet", nullable: false), + CreatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), + UpdatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column<Guid>(type: "uuid", nullable: false), + UpdatedBy = table.Column<Guid>(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_content", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "user", + columns: table => new + { + Id = table.Column<Guid>(type: "uuid", nullable: false), + Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false), + Email = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), + Password = table.Column<string>(type: "text", nullable: false), + LastSeen = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), + CreatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), + UpdatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column<Guid>(type: "uuid", nullable: false), + UpdatedBy = table.Column<Guid>(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_user", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "place", + columns: table => new + { + Id = table.Column<Guid>(type: "uuid", nullable: false), + ContentId = table.Column<Guid>(type: "uuid", nullable: false), + Location = table.Column<Point>(type: "geometry(point,4326)", nullable: false), + CreatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), + UpdatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column<Guid>(type: "uuid", nullable: false), + UpdatedBy = table.Column<Guid>(type: "uuid", nullable: true), + UserId = table.Column<Guid>(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_place", x => x.Id); + table.ForeignKey( + name: "FK_place_content_ContentId", + column: x => x.ContentId, + principalTable: "content", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_place_user_UserId", + column: x => x.UserId, + principalTable: "user", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_audit_trails_EntityName", + table: "audit_trails", + column: "EntityName"); + + migrationBuilder.CreateIndex( + name: "IX_place_ContentId", + table: "place", + column: "ContentId"); + + migrationBuilder.CreateIndex( + name: "IX_place_Location", + table: "place", + column: "Location") + .Annotation("Npgsql:IndexMethod", "gist"); + + migrationBuilder.CreateIndex( + name: "IX_place_UserId", + table: "place", + column: "UserId"); + } + + /// <inheritdoc /> + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "audit_trails"); + + migrationBuilder.DropTable( + name: "place"); + + migrationBuilder.DropTable( + name: "content"); + + migrationBuilder.DropTable( + name: "user"); + } + } +} |
