using System; using System.Collections.Generic; using System.Net; using Microsoft.EntityFrameworkCore.Migrations; using NetTopologySuite.Geometries; #nullable disable namespace WhatApi.Migrations { /// public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", ",,"); migrationBuilder.CreateTable( name: "audit_trails", columns: table => new { Id = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: true), EntityName = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), PrimaryKey = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), TrailType = table.Column(type: "text", nullable: false), DateUtc = table.Column(type: "timestamp with time zone", nullable: false), OldValues = table.Column>(type: "jsonb", nullable: false), NewValues = table.Column>(type: "jsonb", nullable: false), ChangedColumns = table.Column>(type: "jsonb", nullable: false) }, constraints: table => { table.PrimaryKey("PK_audit_trails", x => x.Id); }); migrationBuilder.CreateTable( name: "content", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Mime = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), BlobId = table.Column(type: "uuid", nullable: false), Ip = table.Column(type: "inet", nullable: false), CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAtUtc = table.Column(type: "timestamp with time zone", nullable: true), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("PK_content", x => x.Id); }); migrationBuilder.CreateTable( name: "user", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Email = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Password = table.Column(type: "text", nullable: false), LastSeen = table.Column(type: "timestamp with time zone", nullable: true), CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAtUtc = table.Column(type: "timestamp with time zone", nullable: true), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("PK_user", x => x.Id); }); migrationBuilder.CreateTable( name: "place", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ContentId = table.Column(type: "uuid", nullable: false), Location = table.Column(type: "geometry(point,4326)", nullable: false), CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAtUtc = table.Column(type: "timestamp with time zone", nullable: true), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), UserId = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "audit_trails"); migrationBuilder.DropTable( name: "place"); migrationBuilder.DropTable( name: "content"); migrationBuilder.DropTable( name: "user"); } } }