using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Hutopy.Modules.Memberships.Migrations { /// public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "Memberships"); migrationBuilder.CreateTable( name: "MembershipTiers", schema: "Memberships", columns: table => new { Id = table.Column(type: "uuid", nullable: false), CreatorId = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), Description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: false), Price = table.Column(type: "numeric", nullable: false), CurrencyCode = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), StripeProductId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), StripePriceId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), DeletedBy = table.Column(type: "uuid", nullable: true), DeletedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MembershipTiers", x => x.Id); }); migrationBuilder.CreateTable( name: "Memberships", schema: "Memberships", columns: table => new { Id = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), UserId = table.Column(type: "uuid", nullable: false), CreatorId = table.Column(type: "uuid", nullable: false), TierId = table.Column(type: "uuid", nullable: false), MembershipTierId = table.Column(type: "uuid", nullable: true), State = table.Column(type: "integer", nullable: false), StartDate = table.Column(type: "timestamp with time zone", nullable: true), EndDate = table.Column(type: "timestamp with time zone", nullable: true), StripeSubscriptionId = table.Column(type: "character varying(256)", maxLength: 256, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Memberships", x => x.Id); table.ForeignKey( name: "FK_Memberships_MembershipTiers_MembershipTierId", column: x => x.MembershipTierId, principalSchema: "Memberships", principalTable: "MembershipTiers", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Payments", schema: "Memberships", columns: table => new { Id = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Amount = table.Column(type: "numeric", nullable: false), Currency = table.Column(type: "character varying(8)", maxLength: 8, nullable: false), InvoiceUrl = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false), MembershipId = table.Column(type: "uuid", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Payments", x => x.Id); table.ForeignKey( name: "FK_Payments_Memberships_MembershipId", column: x => x.MembershipId, principalSchema: "Memberships", principalTable: "Memberships", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Memberships_MembershipTierId", schema: "Memberships", table: "Memberships", column: "MembershipTierId"); migrationBuilder.CreateIndex( name: "IX_Payments_MembershipId", schema: "Memberships", table: "Payments", column: "MembershipId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Payments", schema: "Memberships"); migrationBuilder.DropTable( name: "Memberships", schema: "Memberships"); migrationBuilder.DropTable( name: "MembershipTiers", schema: "Memberships"); } } }