feat(workspaces): adds models
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using Api.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace Api.Data;
|
namespace Api.Data;
|
||||||
@@ -8,10 +9,176 @@ public class AppDbContext : DbContext
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DbSet<User> Users => Set<User>();
|
||||||
|
public DbSet<Workspace> Workspaces => Set<Workspace>();
|
||||||
|
public DbSet<Project> Projects => Set<Project>();
|
||||||
|
public DbSet<Domain> Domains => Set<Domain>();
|
||||||
|
public DbSet<ShortLink> ShortLinks => Set<ShortLink>();
|
||||||
|
public DbSet<QRCodeDesign> QRCodeDesigns => Set<QRCodeDesign>();
|
||||||
|
public DbSet<Event> Events => Set<Event>();
|
||||||
|
public DbSet<Asset> Assets => Set<Asset>();
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
// Entity configurations will be added here as entities are created
|
// User configuration
|
||||||
|
modelBuilder.Entity<User>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.HasIndex(e => e.Email).IsUnique();
|
||||||
|
entity.Property(e => e.Email).HasMaxLength(255);
|
||||||
|
entity.Property(e => e.PasswordHash).HasMaxLength(255);
|
||||||
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Workspace configuration
|
||||||
|
modelBuilder.Entity<Workspace>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.Property(e => e.Name).HasMaxLength(100);
|
||||||
|
entity.Property(e => e.Plan).HasConversion<string>().HasMaxLength(20);
|
||||||
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Owner)
|
||||||
|
.WithMany(u => u.Workspaces)
|
||||||
|
.HasForeignKey(e => e.OwnerUserId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Project configuration
|
||||||
|
modelBuilder.Entity<Project>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.Property(e => e.Name).HasMaxLength(100);
|
||||||
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Workspace)
|
||||||
|
.WithMany(w => w.Projects)
|
||||||
|
.HasForeignKey(e => e.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Domain configuration
|
||||||
|
modelBuilder.Entity<Domain>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.HasIndex(e => e.Hostname).IsUnique();
|
||||||
|
entity.Property(e => e.Hostname).HasMaxLength(255);
|
||||||
|
entity.Property(e => e.Status).HasConversion<string>().HasMaxLength(20);
|
||||||
|
entity.Property(e => e.VerificationToken).HasMaxLength(64);
|
||||||
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Workspace)
|
||||||
|
.WithMany(w => w.Domains)
|
||||||
|
.HasForeignKey(e => e.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ShortLink configuration
|
||||||
|
modelBuilder.Entity<ShortLink>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.HasIndex(e => new { e.DomainId, e.Slug }).IsUnique();
|
||||||
|
entity.Property(e => e.Slug).HasMaxLength(50);
|
||||||
|
entity.Property(e => e.DestinationUrl).HasMaxLength(2048);
|
||||||
|
entity.Property(e => e.Title).HasMaxLength(255);
|
||||||
|
entity.Property(e => e.Status).HasConversion<string>().HasMaxLength(20);
|
||||||
|
entity.Property(e => e.PasswordHash).HasMaxLength(255);
|
||||||
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
entity.Property(e => e.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Workspace)
|
||||||
|
.WithMany(w => w.ShortLinks)
|
||||||
|
.HasForeignKey(e => e.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Project)
|
||||||
|
.WithMany(p => p.ShortLinks)
|
||||||
|
.HasForeignKey(e => e.ProjectId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Domain)
|
||||||
|
.WithMany(d => d.ShortLinks)
|
||||||
|
.HasForeignKey(e => e.DomainId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
// QRCodeDesign configuration
|
||||||
|
modelBuilder.Entity<QRCodeDesign>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.Property(e => e.StyleJson).HasColumnType("jsonb");
|
||||||
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
entity.Property(e => e.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Workspace)
|
||||||
|
.WithMany(w => w.QRCodeDesigns)
|
||||||
|
.HasForeignKey(e => e.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Project)
|
||||||
|
.WithMany(p => p.QRCodeDesigns)
|
||||||
|
.HasForeignKey(e => e.ProjectId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
entity.HasOne(e => e.ShortLink)
|
||||||
|
.WithMany(s => s.QRCodeDesigns)
|
||||||
|
.HasForeignKey(e => e.ShortLinkId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
entity.HasOne(e => e.LogoAsset)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(e => e.LogoAssetId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Event configuration
|
||||||
|
modelBuilder.Entity<Event>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.Property(e => e.Type).HasConversion<string>().HasMaxLength(10);
|
||||||
|
entity.Property(e => e.Timestamp).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
entity.Property(e => e.IpHash).HasMaxLength(64);
|
||||||
|
entity.Property(e => e.UserAgent).HasMaxLength(512);
|
||||||
|
entity.Property(e => e.Referrer).HasMaxLength(2048);
|
||||||
|
entity.Property(e => e.CountryCode).HasMaxLength(2);
|
||||||
|
entity.Property(e => e.DeviceType).HasMaxLength(20);
|
||||||
|
entity.Property(e => e.DedupeKey).HasMaxLength(128);
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.Timestamp);
|
||||||
|
entity.HasIndex(e => new { e.ShortLinkId, e.Timestamp });
|
||||||
|
entity.HasIndex(e => new { e.WorkspaceId, e.Timestamp });
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Workspace)
|
||||||
|
.WithMany(w => w.Events)
|
||||||
|
.HasForeignKey(e => e.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
entity.HasOne(e => e.ShortLink)
|
||||||
|
.WithMany(s => s.Events)
|
||||||
|
.HasForeignKey(e => e.ShortLinkId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
entity.HasOne(e => e.QRCode)
|
||||||
|
.WithMany(q => q.Events)
|
||||||
|
.HasForeignKey(e => e.QRCodeId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Asset configuration
|
||||||
|
modelBuilder.Entity<Asset>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id);
|
||||||
|
entity.Property(e => e.Type).HasConversion<string>().HasMaxLength(20);
|
||||||
|
entity.Property(e => e.StorageKey).HasMaxLength(512);
|
||||||
|
entity.Property(e => e.Mime).HasMaxLength(100);
|
||||||
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
entity.HasOne(e => e.Workspace)
|
||||||
|
.WithMany(w => w.Assets)
|
||||||
|
.HasForeignKey(e => e.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
203
src/api/Migrations/20260127192536_InitialCreate.Designer.cs
generated
Normal file
203
src/api/Migrations/20260127192536_InitialCreate.Designer.cs
generated
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Api.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace api.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20260127192536_InitialCreate")]
|
||||||
|
partial class InitialCreate
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "10.0.2")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Domain", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Hostname")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)");
|
||||||
|
|
||||||
|
b.Property<string>("VerificationToken")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Hostname")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId");
|
||||||
|
|
||||||
|
b.ToTable("Domains");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Project", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId");
|
||||||
|
|
||||||
|
b.ToTable("Projects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("VerifiedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Email")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Workspace", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
|
b.Property<Guid>("OwnerUserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Plan")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OwnerUserId");
|
||||||
|
|
||||||
|
b.ToTable("Workspaces");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Domain", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("Domains")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Project", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("Projects")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Workspace", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.User", "Owner")
|
||||||
|
.WithMany("Workspaces")
|
||||||
|
.HasForeignKey("OwnerUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Owner");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Workspaces");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Workspace", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Domains");
|
||||||
|
|
||||||
|
b.Navigation("Projects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
136
src/api/Migrations/20260127192536_InitialCreate.cs
Normal file
136
src/api/Migrations/20260127192536_InitialCreate.cs
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace api.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Users",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Email = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||||
|
PasswordHash = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||||
|
VerifiedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Users", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Workspaces",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
OwnerUserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||||
|
Plan = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Workspaces", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Workspaces_Users_OwnerUserId",
|
||||||
|
column: x => x.OwnerUserId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Domains",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
WorkspaceId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Hostname = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||||
|
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
||||||
|
VerificationToken = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Domains", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Domains_Workspaces_WorkspaceId",
|
||||||
|
column: x => x.WorkspaceId,
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Projects",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
WorkspaceId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Projects", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Projects_Workspaces_WorkspaceId",
|
||||||
|
column: x => x.WorkspaceId,
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Domains_Hostname",
|
||||||
|
table: "Domains",
|
||||||
|
column: "Hostname",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Domains_WorkspaceId",
|
||||||
|
table: "Domains",
|
||||||
|
column: "WorkspaceId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Projects_WorkspaceId",
|
||||||
|
table: "Projects",
|
||||||
|
column: "WorkspaceId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Users_Email",
|
||||||
|
table: "Users",
|
||||||
|
column: "Email",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Workspaces_OwnerUserId",
|
||||||
|
table: "Workspaces",
|
||||||
|
column: "OwnerUserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Domains");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Projects");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Workspaces");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
537
src/api/Migrations/AppDbContextModelSnapshot.cs
Normal file
537
src/api/Migrations/AppDbContextModelSnapshot.cs
Normal file
@@ -0,0 +1,537 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Api.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace api.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
partial class AppDbContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "10.0.2")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Asset", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Mime")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
|
b.Property<long>("Size")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("StorageKey")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(512)
|
||||||
|
.HasColumnType("character varying(512)");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId");
|
||||||
|
|
||||||
|
b.ToTable("Assets");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Domain", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Hostname")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)");
|
||||||
|
|
||||||
|
b.Property<string>("VerificationToken")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Hostname")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId");
|
||||||
|
|
||||||
|
b.ToTable("Domains");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Event", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("CountryCode")
|
||||||
|
.HasMaxLength(2)
|
||||||
|
.HasColumnType("character varying(2)");
|
||||||
|
|
||||||
|
b.Property<string>("DedupeKey")
|
||||||
|
.HasMaxLength(128)
|
||||||
|
.HasColumnType("character varying(128)");
|
||||||
|
|
||||||
|
b.Property<string>("DeviceType")
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)");
|
||||||
|
|
||||||
|
b.Property<string>("IpHash")
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
|
b.Property<Guid?>("QRCodeId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Referrer")
|
||||||
|
.HasMaxLength(2048)
|
||||||
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
|
b.Property<Guid>("ShortLinkId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Timestamp")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(10)
|
||||||
|
.HasColumnType("character varying(10)");
|
||||||
|
|
||||||
|
b.Property<string>("UserAgent")
|
||||||
|
.HasMaxLength(512)
|
||||||
|
.HasColumnType("character varying(512)");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("QRCodeId");
|
||||||
|
|
||||||
|
b.HasIndex("Timestamp");
|
||||||
|
|
||||||
|
b.HasIndex("ShortLinkId", "Timestamp");
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId", "Timestamp");
|
||||||
|
|
||||||
|
b.ToTable("Events");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Project", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId");
|
||||||
|
|
||||||
|
b.ToTable("Projects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.QRCodeDesign", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<Guid?>("LogoAssetId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ProjectId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ShortLinkId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("StyleJson")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("LogoAssetId");
|
||||||
|
|
||||||
|
b.HasIndex("ProjectId");
|
||||||
|
|
||||||
|
b.HasIndex("ShortLinkId");
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId");
|
||||||
|
|
||||||
|
b.ToTable("QRCodeDesigns");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.ShortLink", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("DestinationUrl")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(2048)
|
||||||
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
|
b.Property<Guid?>("DomainId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("ExpiresAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ProjectId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Slug")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("character varying(50)");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<Guid>("WorkspaceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProjectId");
|
||||||
|
|
||||||
|
b.HasIndex("WorkspaceId");
|
||||||
|
|
||||||
|
b.HasIndex("DomainId", "Slug")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("ShortLinks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("VerifiedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Email")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Workspace", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
|
b.Property<Guid>("OwnerUserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Plan")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OwnerUserId");
|
||||||
|
|
||||||
|
b.ToTable("Workspaces");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Asset", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("Assets")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Domain", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("Domains")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Event", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.QRCodeDesign", "QRCode")
|
||||||
|
.WithMany("Events")
|
||||||
|
.HasForeignKey("QRCodeId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Api.Models.ShortLink", "ShortLink")
|
||||||
|
.WithMany("Events")
|
||||||
|
.HasForeignKey("ShortLinkId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("Events")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("QRCode");
|
||||||
|
|
||||||
|
b.Navigation("ShortLink");
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Project", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("Projects")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.QRCodeDesign", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.Asset", "LogoAsset")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("LogoAssetId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Api.Models.Project", "Project")
|
||||||
|
.WithMany("QRCodeDesigns")
|
||||||
|
.HasForeignKey("ProjectId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Api.Models.ShortLink", "ShortLink")
|
||||||
|
.WithMany("QRCodeDesigns")
|
||||||
|
.HasForeignKey("ShortLinkId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("QRCodeDesigns")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("LogoAsset");
|
||||||
|
|
||||||
|
b.Navigation("Project");
|
||||||
|
|
||||||
|
b.Navigation("ShortLink");
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.ShortLink", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.Domain", "Domain")
|
||||||
|
.WithMany("ShortLinks")
|
||||||
|
.HasForeignKey("DomainId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Api.Models.Project", "Project")
|
||||||
|
.WithMany("ShortLinks")
|
||||||
|
.HasForeignKey("ProjectId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Api.Models.Workspace", "Workspace")
|
||||||
|
.WithMany("ShortLinks")
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Domain");
|
||||||
|
|
||||||
|
b.Navigation("Project");
|
||||||
|
|
||||||
|
b.Navigation("Workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Workspace", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Api.Models.User", "Owner")
|
||||||
|
.WithMany("Workspaces")
|
||||||
|
.HasForeignKey("OwnerUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Owner");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Domain", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("ShortLinks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Project", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("QRCodeDesigns");
|
||||||
|
|
||||||
|
b.Navigation("ShortLinks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.QRCodeDesign", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Events");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.ShortLink", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Events");
|
||||||
|
|
||||||
|
b.Navigation("QRCodeDesigns");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Workspaces");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Api.Models.Workspace", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Assets");
|
||||||
|
|
||||||
|
b.Navigation("Domains");
|
||||||
|
|
||||||
|
b.Navigation("Events");
|
||||||
|
|
||||||
|
b.Navigation("Projects");
|
||||||
|
|
||||||
|
b.Navigation("QRCodeDesigns");
|
||||||
|
|
||||||
|
b.Navigation("ShortLinks");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/api/Models/Domain.cs
Normal file
22
src/api/Models/Domain.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
namespace Api.Models;
|
||||||
|
|
||||||
|
public enum DomainStatus
|
||||||
|
{
|
||||||
|
Pending,
|
||||||
|
Verified,
|
||||||
|
Active
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Domain
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid WorkspaceId { get; set; }
|
||||||
|
public required string Hostname { get; set; }
|
||||||
|
public DomainStatus Status { get; set; } = DomainStatus.Pending;
|
||||||
|
public required string VerificationToken { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
// Navigation properties
|
||||||
|
public Workspace Workspace { get; set; } = null!;
|
||||||
|
public ICollection<ShortLink> ShortLinks { get; set; } = [];
|
||||||
|
}
|
||||||
14
src/api/Models/Project.cs
Normal file
14
src/api/Models/Project.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
namespace Api.Models;
|
||||||
|
|
||||||
|
public class Project
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid WorkspaceId { get; set; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
// Navigation properties
|
||||||
|
public Workspace Workspace { get; set; } = null!;
|
||||||
|
public ICollection<ShortLink> ShortLinks { get; set; } = [];
|
||||||
|
public ICollection<QRCodeDesign> QRCodeDesigns { get; set; } = [];
|
||||||
|
}
|
||||||
13
src/api/Models/User.cs
Normal file
13
src/api/Models/User.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace Api.Models;
|
||||||
|
|
||||||
|
public class User
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public required string Email { get; set; }
|
||||||
|
public required string PasswordHash { get; set; }
|
||||||
|
public DateTime? VerifiedAt { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
// Navigation properties
|
||||||
|
public ICollection<Workspace> Workspaces { get; set; } = [];
|
||||||
|
}
|
||||||
26
src/api/Models/Workspace.cs
Normal file
26
src/api/Models/Workspace.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
namespace Api.Models;
|
||||||
|
|
||||||
|
public enum WorkspacePlan
|
||||||
|
{
|
||||||
|
Free,
|
||||||
|
Pro,
|
||||||
|
Business
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Workspace
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid OwnerUserId { get; set; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public WorkspacePlan Plan { get; set; } = WorkspacePlan.Free;
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
// Navigation properties
|
||||||
|
public User Owner { get; set; } = null!;
|
||||||
|
public ICollection<Project> Projects { get; set; } = [];
|
||||||
|
public ICollection<Domain> Domains { get; set; } = [];
|
||||||
|
public ICollection<ShortLink> ShortLinks { get; set; } = [];
|
||||||
|
public ICollection<QRCodeDesign> QRCodeDesigns { get; set; } = [];
|
||||||
|
public ICollection<Event> Events { get; set; } = [];
|
||||||
|
public ICollection<Asset> Assets { get; set; } = [];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user