summaryrefslogtreecommitdiff
path: root/src/marlin.web/Migrations/20260906003038_AddWorkflowSnapshot.cs
blob: d47ee9ec1561e496834ef3f590abc352743b2bc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace marlin.web.Migrations
{
    /// <inheritdoc />
    public partial class AddWorkflowSnapshot : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<bool>(
                name: "workflow_scanned",
                table: "source_commits",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.CreateTable(
                name: "workflow_snapshots",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    commit_id = table.Column<Guid>(type: "uuid", nullable: false),
                    scanned_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    workflow = table.Column<string>(type: "text", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_workflow_snapshots", x => x.id);
                    table.ForeignKey(
                        name: "fk_workflow_snapshots_source_commits_commit_id",
                        column: x => x.commit_id,
                        principalTable: "source_commits",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "ix_workflow_snapshots_commit_id",
                table: "workflow_snapshots",
                column: "commit_id",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "workflow_snapshots");

            migrationBuilder.DropColumn(
                name: "workflow_scanned",
                table: "source_commits");
        }
    }
}