All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Created Dockerfile for packing up API and Web projects as Docker image
145 lines
6.3 KiB
C#
145 lines
6.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
namespace YABA.Data.Migrations
|
|
{
|
|
public partial class InitialMigration : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "users",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
is_deleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
created_on = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
last_modified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
auth0id = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_users", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "bookmarks",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
is_deleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
created_on = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
last_modified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
title = table.Column<string>(type: "text", nullable: false),
|
|
description = table.Column<string>(type: "text", nullable: false),
|
|
note = table.Column<string>(type: "text", nullable: false),
|
|
is_hidden = table.Column<bool>(type: "boolean", nullable: false),
|
|
user_id = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_bookmarks", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_bookmarks_users_user_id",
|
|
column: x => x.user_id,
|
|
principalTable: "users",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "tags",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
is_deleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
name = table.Column<string>(type: "text", nullable: false),
|
|
is_hidden = table.Column<bool>(type: "boolean", nullable: false),
|
|
user_id = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_tags", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_tags_users_user_id",
|
|
column: x => x.user_id,
|
|
principalTable: "users",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "bookmark_tags",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
bookmark_id = table.Column<int>(type: "integer", nullable: false),
|
|
tag_id = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_bookmark_tags", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_bookmark_tags_bookmarks_bookmark_id",
|
|
column: x => x.bookmark_id,
|
|
principalTable: "bookmarks",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "fk_bookmark_tags_tags_tag_id",
|
|
column: x => x.tag_id,
|
|
principalTable: "tags",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_bookmark_tags_bookmark_id_tag_id",
|
|
table: "bookmark_tags",
|
|
columns: new[] { "bookmark_id", "tag_id" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_bookmark_tags_tag_id",
|
|
table: "bookmark_tags",
|
|
column: "tag_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_bookmarks_user_id",
|
|
table: "bookmarks",
|
|
column: "user_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_tags_user_id",
|
|
table: "tags",
|
|
column: "user_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_users_auth0id",
|
|
table: "users",
|
|
column: "auth0id",
|
|
unique: true);
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "bookmark_tags");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "bookmarks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "tags");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "users");
|
|
}
|
|
}
|
|
}
|