using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace ExpenseTracker.Api.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "app_settings", columns: table => new { id = table.Column(type: "uuid", nullable: false), key = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), value = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_app_settings", x => x.id); }); migrationBuilder.CreateTable( name: "categories", columns: table => new { id = table.Column(type: "uuid", nullable: false), name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), color = table.Column(type: "character varying(7)", maxLength: 7, nullable: false) }, constraints: table => { table.PrimaryKey("PK_categories", x => x.id); }); migrationBuilder.CreateTable( name: "months", columns: table => new { id = table.Column(type: "uuid", nullable: false), year = table.Column(type: "integer", nullable: false), month = table.Column(type: "integer", nullable: false), default_salary = table.Column(type: "numeric(12,2)", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_months", x => x.id); }); migrationBuilder.CreateTable( name: "entries", columns: table => new { id = table.Column(type: "uuid", nullable: false), month_id = table.Column(type: "uuid", nullable: false), type = table.Column(type: "text", nullable: false), amount = table.Column(type: "numeric(12,2)", nullable: false), label = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), category_id = table.Column(type: "uuid", nullable: true), entry_date = table.Column(type: "date", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_entries", x => x.id); table.ForeignKey( name: "FK_entries_categories_category_id", column: x => x.category_id, principalTable: "categories", principalColumn: "id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_entries_months_month_id", column: x => x.month_id, principalTable: "months", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "app_settings", columns: new[] { "id", "key", "value" }, values: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), "default_salary", "0" }); migrationBuilder.InsertData( table: "categories", columns: new[] { "id", "color", "name" }, values: new object[,] { { new Guid("10000000-0000-0000-0000-000000000001"), "#ef4444", "Alimentation" }, { new Guid("10000000-0000-0000-0000-000000000002"), "#f97316", "Transport" }, { new Guid("10000000-0000-0000-0000-000000000003"), "#eab308", "Logement" }, { new Guid("10000000-0000-0000-0000-000000000004"), "#22c55e", "Santé" }, { new Guid("10000000-0000-0000-0000-000000000005"), "#3b82f6", "Loisirs" }, { new Guid("10000000-0000-0000-0000-000000000006"), "#a855f7", "Abonnements" }, { new Guid("10000000-0000-0000-0000-000000000007"), "#6b7280", "Autre" } }); migrationBuilder.CreateIndex( name: "ix_app_settings_key_unique", table: "app_settings", column: "key", unique: true); migrationBuilder.CreateIndex( name: "ix_entries_category_id", table: "entries", column: "category_id"); migrationBuilder.CreateIndex( name: "ix_entries_month_id", table: "entries", column: "month_id"); migrationBuilder.CreateIndex( name: "ix_months_year_month_unique", table: "months", columns: new[] { "year", "month" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "app_settings"); migrationBuilder.DropTable( name: "entries"); migrationBuilder.DropTable( name: "categories"); migrationBuilder.DropTable( name: "months"); } } }