aboutsummaryrefslogtreecommitdiffstats
path: root/src/Migrations/20210305140605_CleanSlate.cs
blob: bde6c16839dc9f99181279064010cd7f7765185c (plain) (blame)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System;
using System.Collections.Generic;
using IOL.VippsEcommerce.Models.Api;
using Microsoft.EntityFrameworkCore.Migrations;
using VSH.Data.Database;

namespace VSH.Migrations
{
    public partial class CleanSlate : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    name = table.Column<string>(type: "text", nullable: true),
                    slug = table.Column<string>(type: "text", nullable: true),
                    visibility_state = table.Column<int>(type: "integer", nullable: false),
                    created = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    updated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_categories", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "Documents",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    type = table.Column<int>(type: "integer", nullable: false),
                    content = table.Column<string>(type: "text", nullable: true),
                    created = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    updated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_documents", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "Orders",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    comment = table.Column<string>(type: "text", nullable: true),
                    order_reference = table.Column<string>(type: "text", nullable: true),
                    status = table.Column<int>(type: "integer", nullable: false),
                    payment_type = table.Column<int>(type: "integer", nullable: false),
                    contact_info = table.Column<Order.ContactInformation>(type: "jsonb", nullable: true),
                    products = table.Column<List<OrderProduct>>(type: "jsonb", nullable: true),
                    created = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    updated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_orders", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "Users",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    username = table.Column<string>(type: "text", nullable: true),
                    password = table.Column<string>(type: "text", nullable: true),
                    created = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    updated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_users", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "Products",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    name = table.Column<string>(type: "text", nullable: true),
                    description = table.Column<string>(type: "text", nullable: true),
                    price = table.Column<decimal>(type: "numeric", nullable: false),
                    price_suffix = table.Column<int>(type: "integer", nullable: false),
                    visibility_state = table.Column<int>(type: "integer", nullable: false),
                    category_id = table.Column<Guid>(type: "uuid", nullable: true),
                    images = table.Column<List<ProductImage>>(type: "jsonb", nullable: true),
                    count = table.Column<int>(type: "integer", nullable: false),
                    slug = table.Column<string>(type: "text", nullable: true),
                    show_on_frontpage = table.Column<bool>(type: "boolean", nullable: false),
                    created = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    updated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_products", x => x.id);
                    table.ForeignKey(
                        name: "fk_products_categories_category_id",
                        column: x => x.category_id,
                        principalTable: "Categories",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
               name: "VippsResponses",
               columns: table => new
               {
                   id = table.Column<Guid>(type: "uuid", nullable: false),
                   order_id = table.Column<Guid>(type: "uuid", nullable: false),
                   status_code = table.Column<int>(type: "integer", nullable: false),
                   initiation_response = table.Column<VippsPaymentInitiationCallbackResponse>(type: "jsonb", nullable: true),
                   payment_detail_response = table.Column<VippsGetPaymentDetailsResponse>(type: "jsonb", nullable: true),
                   cancellation_response = table.Column<VippsPaymentActionResponse>(type: "jsonb", nullable: true),
                   refund_response = table.Column<VippsPaymentActionResponse>(type: "jsonb", nullable: true),
                   capture_response = table.Column<VippsPaymentActionResponse>(type: "jsonb", nullable: true),
                   error_response = table.Column<VippsErrorResponse>(type: "jsonb", nullable: true),
                   created = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                   updated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
               },
               constraints: table =>
               {
                   table.PrimaryKey("pk_vipps_responses", x => x.id);
                   table.ForeignKey(
                       name: "fk_vipps_responses_orders_order_id",
                       column: x => x.order_id,
                       principalTable: "Orders",
                       principalColumn: "id",
                       onDelete: ReferentialAction.Cascade);
               });

            migrationBuilder.CreateIndex(
                name: "ix_products_category_id",
                table: "Products",
                column: "category_id");

            migrationBuilder.CreateIndex(
                name: "ix_vipps_responses_order_id",
                table: "VippsResponses",
                column: "order_id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Documents");

            migrationBuilder.DropTable(
                name: "Products");

            migrationBuilder.DropTable(
                name: "Users");

            migrationBuilder.DropTable(
                name: "VippsResponses");

            migrationBuilder.DropTable(
                name: "Categories");

            migrationBuilder.DropTable(
                name: "Orders");
        }
    }
}