diff --git a/barkmanAPI/Migrations/20250109192017_InitialCreate.Designer.cs b/barkmanAPI/Migrations/20250109192017_InitialCreate.Designer.cs
deleted file mode 100644
index 8317692..0000000
--- a/barkmanAPI/Migrations/20250109192017_InitialCreate.Designer.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace barkmanapi.Migrations
-{
- [DbContext(typeof(BarkContext))]
- [Migration("20250109192017_InitialCreate")]
- partial class InitialCreate
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
-
- modelBuilder.Entity("InventoryItems", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Brand")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Notes")
- .HasColumnType("TEXT");
-
- b.Property("RentalPrice")
- .HasColumnType("REAL");
-
- b.Property("ReplacementCost")
- .HasColumnType("REAL");
-
- b.Property("SerialNumber")
- .HasColumnType("TEXT");
-
- b.Property("Status")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Inventory");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/barkmanAPI/Migrations/20250109192017_InitialCreate.cs b/barkmanAPI/Migrations/20250109192017_InitialCreate.cs
deleted file mode 100644
index eac0eca..0000000
--- a/barkmanAPI/Migrations/20250109192017_InitialCreate.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace barkmanapi.Migrations
-{
- ///
- public partial class InitialCreate : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Inventory",
- columns: table => new
- {
- Id = table.Column(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Name = table.Column(type: "TEXT", nullable: false),
- Brand = table.Column(type: "TEXT", nullable: false),
- SerialNumber = table.Column(type: "TEXT", nullable: true),
- Status = table.Column(type: "TEXT", nullable: true),
- RentalPrice = table.Column(type: "REAL", nullable: true),
- ReplacementCost = table.Column(type: "REAL", nullable: true),
- Notes = table.Column(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Inventory", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Inventory");
- }
- }
-}
diff --git a/barkmanAPI/Migrations/20250122011527_postyFirst.Designer.cs b/barkmanAPI/Migrations/20250122011527_postyFirst.Designer.cs
new file mode 100644
index 0000000..50a6aa3
--- /dev/null
+++ b/barkmanAPI/Migrations/20250122011527_postyFirst.Designer.cs
@@ -0,0 +1,74 @@
+//
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using barkmanapi;
+
+#nullable disable
+
+namespace barkmanapi.Migrations
+{
+ [DbContext(typeof(BarkContext))]
+ [Migration("20250122011527_postyFirst")]
+ partial class postyFirst
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.1")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("barkmanapi.InventoryItems", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Brand")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("brand");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("name");
+
+ b.Property("Notes")
+ .HasColumnType("text")
+ .HasColumnName("notes");
+
+ b.Property("RentalPrice")
+ .HasColumnType("real")
+ .HasColumnName("rental_price");
+
+ b.Property("ReplacementCost")
+ .HasColumnType("real")
+ .HasColumnName("replacement_cost");
+
+ b.Property("SerialNumber")
+ .HasColumnType("text")
+ .HasColumnName("serial_number");
+
+ b.Property("Status")
+ .HasColumnType("text")
+ .HasColumnName("status");
+
+ b.HasKey("Id")
+ .HasName("pk_inventory");
+
+ b.ToTable("inventory", (string)null);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/barkmanAPI/Migrations/20250122011527_postyFirst.cs b/barkmanAPI/Migrations/20250122011527_postyFirst.cs
new file mode 100644
index 0000000..599a405
--- /dev/null
+++ b/barkmanAPI/Migrations/20250122011527_postyFirst.cs
@@ -0,0 +1,41 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace barkmanapi.Migrations
+{
+ ///
+ public partial class postyFirst : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "inventory",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ name = table.Column(type: "text", nullable: false),
+ brand = table.Column(type: "text", nullable: false),
+ serial_number = table.Column(type: "text", nullable: true),
+ status = table.Column(type: "text", nullable: true),
+ rental_price = table.Column(type: "real", nullable: true),
+ replacement_cost = table.Column(type: "real", nullable: true),
+ notes = table.Column(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pk_inventory", x => x.id);
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "inventory");
+ }
+ }
+}
diff --git a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs b/barkmanAPI/Migrations/BarkContextModelSnapshot.cs
index cdf858a..ab7aae2 100644
--- a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs
+++ b/barkmanAPI/Migrations/BarkContextModelSnapshot.cs
@@ -2,6 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using barkmanapi;
#nullable disable
@@ -13,40 +15,55 @@ namespace barkmanapi.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.1")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
- modelBuilder.Entity("InventoryItems", b =>
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("barkmanapi.InventoryItems", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("Brand")
.IsRequired()
- .HasColumnType("TEXT");
+ .HasColumnType("text")
+ .HasColumnName("brand");
b.Property("Name")
.IsRequired()
- .HasColumnType("TEXT");
+ .HasColumnType("text")
+ .HasColumnName("name");
b.Property("Notes")
- .HasColumnType("TEXT");
+ .HasColumnType("text")
+ .HasColumnName("notes");
b.Property("RentalPrice")
- .HasColumnType("REAL");
+ .HasColumnType("real")
+ .HasColumnName("rental_price");
b.Property("ReplacementCost")
- .HasColumnType("REAL");
+ .HasColumnType("real")
+ .HasColumnName("replacement_cost");
b.Property("SerialNumber")
- .HasColumnType("TEXT");
+ .HasColumnType("text")
+ .HasColumnName("serial_number");
b.Property("Status")
- .HasColumnType("TEXT");
+ .HasColumnType("text")
+ .HasColumnName("status");
- b.HasKey("Id");
+ b.HasKey("Id")
+ .HasName("pk_inventory");
- b.ToTable("Inventory");
+ b.ToTable("inventory", (string)null);
});
#pragma warning restore 612, 618
}
diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs
index ebf25cd..6c46e45 100644
--- a/barkmanAPI/Program.cs
+++ b/barkmanAPI/Program.cs
@@ -1,3 +1,4 @@
+using barkmanapi;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
@@ -20,6 +21,9 @@ builder.Services.AddCors(options =>
policy.WithOrigins("https://barkdev.ts.drewr.io", "http://localhost:5173").AllowAnyMethod().AllowAnyHeader();
});
});
+builder.Services.AddDbContext(opt =>
+ opt.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")).UseSnakeCaseNamingConvention());
+
var app = builder.Build();
if (!app.Environment.IsProduction())
@@ -34,7 +38,7 @@ if (!app.Environment.IsProduction())
app.MapGet("/", () => "Hello World!");
app.MapGet("/inventory", async (BarkContext db) =>
- await db.Inventory.ToListAsync());
+ await db.Inventory.OrderBy(item=>item.Id).ToListAsync());
app.MapGet("/inventory/{id}", async (int id, BarkContext db) =>
{
diff --git a/barkmanAPI/barkDbModel.cs b/barkmanAPI/barkDbModel.cs
index 84799d7..88b538c 100644
--- a/barkmanAPI/barkDbModel.cs
+++ b/barkmanAPI/barkDbModel.cs
@@ -1,24 +1,10 @@
using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-public class BarkContext : DbContext
+namespace barkmanapi;
+
+public class BarkContext(DbContextOptions options) : DbContext(options)
{
public DbSet Inventory { get; set; }
-
- public string DbPath { get; }
-
- public BarkContext()
- {
- var folder = Environment.SpecialFolder.LocalApplicationData;
- var path = Environment.GetFolderPath(folder);
- DbPath = "./database/app.db";
- }
-
- // The following configures EF to create a Sqlite database file in the
- // special "local" folder for your platform.
- protected override void OnConfiguring(DbContextOptionsBuilder options)
- => options.UseSqlite($"Data Source={DbPath}");
}
public class InventoryItems
@@ -31,5 +17,4 @@ public class InventoryItems
public float? RentalPrice { get; set; }
public float? ReplacementCost { get; set; }
public string? Notes { get; set; }
-}
-
+}
\ No newline at end of file
diff --git a/barkmanAPI/barkmanapi.csproj b/barkmanAPI/barkmanapi.csproj
index 7b95621..fa775f1 100644
--- a/barkmanAPI/barkmanapi.csproj
+++ b/barkmanAPI/barkmanapi.csproj
@@ -5,15 +5,17 @@
enable
enable
Linux
+ a965d65f-8c78-4549-9c7c-8c4d221a8a02
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
diff --git a/barkmanui/.env b/barkmanui/.env
index 29a2dbd..c62e21a 100644
--- a/barkmanui/.env
+++ b/barkmanui/.env
@@ -1 +1 @@
-VITE_API_URL=https://barkdev.ts.drewr.io
\ No newline at end of file
+VITE_API_URL=http://localhost:5145
\ No newline at end of file