From 2ef9843615b913618d5f2e92844416024903a389 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Mon, 18 Sep 2023 13:37:15 +0200 Subject: [PATCH] :card_file_box: included migrations for init Co-authored-by: Sindre Kjelsrud --- backend/.vscode/launch.json | 38 +++++++++++++ backend/.vscode/tasks.json | 41 ++++++++++++++ backend/Context/DbContext.cs | 2 +- .../20230918090830_V1__init.Designer.cs | 56 +++++++++++++++++++ backend/Migrations/20230918090830_V1__init.cs | 39 +++++++++++++ ...20230918094524_V2__insert_data.Designer.cs | 56 +++++++++++++++++++ .../20230918094524_V2__insert_data.cs | 22 ++++++++ .../Migrations/MovieDbContextModelSnapshot.cs | 53 ++++++++++++++++++ backend/start.sh | 0 9 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 backend/.vscode/launch.json create mode 100644 backend/.vscode/tasks.json create mode 100644 backend/Migrations/20230918090830_V1__init.Designer.cs create mode 100644 backend/Migrations/20230918090830_V1__init.cs create mode 100644 backend/Migrations/20230918094524_V2__insert_data.Designer.cs create mode 100644 backend/Migrations/20230918094524_V2__insert_data.cs create mode 100644 backend/Migrations/MovieDbContextModelSnapshot.cs create mode 100644 backend/start.sh diff --git a/backend/.vscode/launch.json b/backend/.vscode/launch.json new file mode 100644 index 0000000..6f4affd --- /dev/null +++ b/backend/.vscode/launch.json @@ -0,0 +1,38 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md. + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net7.0/backend.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/backend/.vscode/tasks.json b/backend/.vscode/tasks.json new file mode 100644 index 0000000..f273a9d --- /dev/null +++ b/backend/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/backend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/backend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/backend.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/backend/Context/DbContext.cs b/backend/Context/DbContext.cs index 61cfa8d..79eeb01 100644 --- a/backend/Context/DbContext.cs +++ b/backend/Context/DbContext.cs @@ -7,5 +7,5 @@ public class MovieDbContext: DbContext { } - public DbSet Movies { get; set; } + public DbSet Movies { get; set; } } \ No newline at end of file diff --git a/backend/Migrations/20230918090830_V1__init.Designer.cs b/backend/Migrations/20230918090830_V1__init.Designer.cs new file mode 100644 index 0000000..2953f58 --- /dev/null +++ b/backend/Migrations/20230918090830_V1__init.Designer.cs @@ -0,0 +1,56 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace backend.Migrations +{ + [DbContext(typeof(MovieDbContext))] + [Migration("20230918090830_V1__init")] + partial class V1__init + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("backend.MovieDB", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Poster") + .HasColumnType("text"); + + b.Property("Title") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("text"); + + b.Property("Year") + .HasColumnType("text"); + + b.Property("imdbID") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Movies"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/Migrations/20230918090830_V1__init.cs b/backend/Migrations/20230918090830_V1__init.cs new file mode 100644 index 0000000..3307df4 --- /dev/null +++ b/backend/Migrations/20230918090830_V1__init.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace backend.Migrations +{ + /// + public partial class V1__init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Movies", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column(type: "text", nullable: true), + Year = table.Column(type: "text", nullable: true), + imdbID = table.Column(type: "text", nullable: true), + Type = table.Column(type: "text", nullable: true), + Poster = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Movies", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Movies"); + } + } +} diff --git a/backend/Migrations/20230918094524_V2__insert_data.Designer.cs b/backend/Migrations/20230918094524_V2__insert_data.Designer.cs new file mode 100644 index 0000000..581a00c --- /dev/null +++ b/backend/Migrations/20230918094524_V2__insert_data.Designer.cs @@ -0,0 +1,56 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace backend.Migrations +{ + [DbContext(typeof(MovieDbContext))] + [Migration("20230918094524_V2__insert_data")] + partial class V2__insert_data + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("backend.MovieDB", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Poster") + .HasColumnType("text"); + + b.Property("Title") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("text"); + + b.Property("Year") + .HasColumnType("text"); + + b.Property("imdbID") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Movies"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/Migrations/20230918094524_V2__insert_data.cs b/backend/Migrations/20230918094524_V2__insert_data.cs new file mode 100644 index 0000000..9208049 --- /dev/null +++ b/backend/Migrations/20230918094524_V2__insert_data.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace backend.Migrations +{ + /// + public partial class V2__insert_data : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + // insert to db + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/backend/Migrations/MovieDbContextModelSnapshot.cs b/backend/Migrations/MovieDbContextModelSnapshot.cs new file mode 100644 index 0000000..c0199f0 --- /dev/null +++ b/backend/Migrations/MovieDbContextModelSnapshot.cs @@ -0,0 +1,53 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace backend.Migrations +{ + [DbContext(typeof(MovieDbContext))] + partial class MovieDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("backend.MovieDB", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Poster") + .HasColumnType("text"); + + b.Property("Title") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("text"); + + b.Property("Year") + .HasColumnType("text"); + + b.Property("imdbID") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Movies"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/start.sh b/backend/start.sh new file mode 100644 index 0000000..e69de29