Initial commit

This commit is contained in:
Kevin Harlay
2026-09-07 13:33:22 +02:00
commit ebfaf6f5ec
295 changed files with 8786 additions and 0 deletions
+145
View File
@@ -0,0 +1,145 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace ExpenseTracker.Api.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "app_settings",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
key = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
value = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_app_settings", x => x.id);
});
migrationBuilder.CreateTable(
name: "categories",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
color = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
year = table.Column<int>(type: "integer", nullable: false),
month = table.Column<int>(type: "integer", nullable: false),
default_salary = table.Column<decimal>(type: "numeric(12,2)", nullable: false),
created_at = table.Column<DateTime>(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<Guid>(type: "uuid", nullable: false),
month_id = table.Column<Guid>(type: "uuid", nullable: false),
type = table.Column<string>(type: "text", nullable: false),
amount = table.Column<decimal>(type: "numeric(12,2)", nullable: false),
label = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
category_id = table.Column<Guid>(type: "uuid", nullable: true),
entry_date = table.Column<DateOnly>(type: "date", nullable: false),
created_at = table.Column<DateTime>(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);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "app_settings");
migrationBuilder.DropTable(
name: "entries");
migrationBuilder.DropTable(
name: "categories");
migrationBuilder.DropTable(
name: "months");
}
}
}