using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace GerstITS.Examples.Data.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "examples"); migrationBuilder.CreateTable( name: "Customers", schema: "examples", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), FirstName = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), LastName = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), EMail = table.Column(type: "character varying(250)", maxLength: 250, nullable: false), IsActive = table.Column(type: "boolean", nullable: false), Deactivated = table.Column(type: "timestamp with time zone", nullable: true), DeactivatedBy = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), Created = table.Column(type: "timestamp with time zone", nullable: false), CreatedBy = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), Modified = table.Column(type: "timestamp with time zone", nullable: true), ModifiedBy = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), Version = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Customers", x => x.Id); }); migrationBuilder.CreateTable( name: "CustomerNotes", schema: "examples", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), CustomerId = table.Column(type: "integer", nullable: false), Text = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: false), Created = table.Column(type: "timestamp with time zone", nullable: false), CreatedBy = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), HistorySet = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), ValidFrom = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CustomerNotes", x => x.Id); table.ForeignKey( name: "FK_CustomerNotes_Customers_CustomerId", column: x => x.CustomerId, principalSchema: "examples", principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_CustomerNotes_CustomerId", schema: "examples", table: "CustomerNotes", column: "CustomerId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "CustomerNotes", schema: "examples"); migrationBuilder.DropTable( name: "Customers", schema: "examples"); } } }