Add Master Data
This commit is contained in:
2176
AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.Designer.cs
generated
Normal file
2176
AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,348 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AMREZ.EOP.Infrastructures.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddCustomer : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "addresses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Line1 = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||
Line2 = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||
Village = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
Soi = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
Road = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
Subdistrict = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
District = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
Province = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
PostalCode = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: true),
|
||||
CountryCode = table.Column<string>(type: "character varying(2)", maxLength: 2, nullable: false),
|
||||
Verified = table.Column<bool>(type: "boolean", nullable: false),
|
||||
GeoLat = table.Column<double>(type: "double precision", nullable: true),
|
||||
GeoLng = table.Column<double>(type: "double precision", nullable: true),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
created_by = table.Column<string>(type: "text", nullable: true),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
updated_by = table.Column<string>(type: "text", nullable: true),
|
||||
is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_addresses", x => x.Id);
|
||||
table.UniqueConstraint("AK_addresses_tenant_id_Id", x => new { x.tenant_id, x.Id });
|
||||
table.CheckConstraint("ck_addresses_tenant_not_null", "tenant_id is not null");
|
||||
table.CheckConstraint("ck_addresses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "customer_profiles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Type = table.Column<int>(type: "integer", nullable: false),
|
||||
DisplayName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
created_by = table.Column<string>(type: "text", nullable: true),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
updated_by = table.Column<string>(type: "text", nullable: true),
|
||||
is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_customer_profiles", x => x.Id);
|
||||
table.UniqueConstraint("AK_customer_profiles_tenant_id_Id", x => new { x.tenant_id, x.Id });
|
||||
table.CheckConstraint("ck_customer_profiles_tenant_not_null", "tenant_id is not null");
|
||||
table.CheckConstraint("ck_customer_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "customer_addresses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CustomerProfileId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
AddressId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Label = table.Column<int>(type: "integer", nullable: false),
|
||||
IsDefault = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
created_by = table.Column<string>(type: "text", nullable: true),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
updated_by = table.Column<string>(type: "text", nullable: true),
|
||||
is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_customer_addresses", x => x.Id);
|
||||
table.CheckConstraint("ck_customer_addresses_tenant_not_null", "tenant_id is not null");
|
||||
table.CheckConstraint("ck_customer_addresses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
|
||||
table.ForeignKey(
|
||||
name: "FK_customer_addresses_addresses_tenant_id_AddressId",
|
||||
columns: x => new { x.tenant_id, x.AddressId },
|
||||
principalTable: "addresses",
|
||||
principalColumns: new[] { "tenant_id", "Id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_customer_addresses_customer_profiles_tenant_id_CustomerProf~",
|
||||
columns: x => new { x.tenant_id, x.CustomerProfileId },
|
||||
principalTable: "customer_profiles",
|
||||
principalColumns: new[] { "tenant_id", "Id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "customer_contacts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CustomerProfileId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Type = table.Column<int>(type: "integer", nullable: false),
|
||||
Value = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||
IsPrimary = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
|
||||
IsVerified = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
created_by = table.Column<string>(type: "text", nullable: true),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
updated_by = table.Column<string>(type: "text", nullable: true),
|
||||
is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_customer_contacts", x => x.Id);
|
||||
table.CheckConstraint("ck_customer_contacts_tenant_not_null", "tenant_id is not null");
|
||||
table.CheckConstraint("ck_customer_contacts_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
|
||||
table.ForeignKey(
|
||||
name: "FK_customer_contacts_customer_profiles_tenant_id_CustomerProfi~",
|
||||
columns: x => new { x.tenant_id, x.CustomerProfileId },
|
||||
principalTable: "customer_profiles",
|
||||
principalColumns: new[] { "tenant_id", "Id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "customer_tags",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CustomerProfileId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Tag = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
created_by = table.Column<string>(type: "text", nullable: true),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
updated_by = table.Column<string>(type: "text", nullable: true),
|
||||
is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_customer_tags", x => x.Id);
|
||||
table.CheckConstraint("ck_customer_tags_tenant_not_null", "tenant_id is not null");
|
||||
table.CheckConstraint("ck_customer_tags_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
|
||||
table.ForeignKey(
|
||||
name: "FK_customer_tags_customer_profiles_tenant_id_CustomerProfileId",
|
||||
columns: x => new { x.tenant_id, x.CustomerProfileId },
|
||||
principalTable: "customer_profiles",
|
||||
principalColumns: new[] { "tenant_id", "Id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "organization_profiles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CustomerProfileId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
LegalNameTh = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||
LegalNameEn = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||
RegistrationNo = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
TaxId13 = table.Column<string>(type: "character varying(13)", maxLength: 13, nullable: true),
|
||||
BranchCode = table.Column<string>(type: "character varying(5)", maxLength: 5, nullable: true),
|
||||
CompanyType = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
created_by = table.Column<string>(type: "text", nullable: true),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
updated_by = table.Column<string>(type: "text", nullable: true),
|
||||
is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_organization_profiles", x => x.Id);
|
||||
table.CheckConstraint("ck_organization_profiles_tenant_not_null", "tenant_id is not null");
|
||||
table.CheckConstraint("ck_organization_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
|
||||
table.ForeignKey(
|
||||
name: "FK_organization_profiles_customer_profiles_tenant_id_CustomerP~",
|
||||
columns: x => new { x.tenant_id, x.CustomerProfileId },
|
||||
principalTable: "customer_profiles",
|
||||
principalColumns: new[] { "tenant_id", "Id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "person_profiles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CustomerProfileId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Prefix = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
FirstNameTh = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
LastNameTh = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
FirstNameEn = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
LastNameEn = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
BirthDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
NationalId = table.Column<string>(type: "character varying(13)", maxLength: 13, nullable: true),
|
||||
PassportNo = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
created_by = table.Column<string>(type: "text", nullable: true),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
updated_by = table.Column<string>(type: "text", nullable: true),
|
||||
is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_person_profiles", x => x.Id);
|
||||
table.CheckConstraint("ck_person_profiles_tenant_not_null", "tenant_id is not null");
|
||||
table.CheckConstraint("ck_person_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
|
||||
table.ForeignKey(
|
||||
name: "FK_person_profiles_customer_profiles_tenant_id_CustomerProfile~",
|
||||
columns: x => new { x.tenant_id, x.CustomerProfileId },
|
||||
principalTable: "customer_profiles",
|
||||
principalColumns: new[] { "tenant_id", "Id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_addresses_tenant_id",
|
||||
table: "addresses",
|
||||
column: "tenant_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_addresses_tenant_id",
|
||||
table: "customer_addresses",
|
||||
column: "tenant_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_addresses_tenant_id_AddressId",
|
||||
table: "customer_addresses",
|
||||
columns: new[] { "tenant_id", "AddressId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_addresses_tenant_id_CustomerProfileId_Label",
|
||||
table: "customer_addresses",
|
||||
columns: new[] { "tenant_id", "CustomerProfileId", "Label" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ux_default_customer_address_per_label",
|
||||
table: "customer_addresses",
|
||||
columns: new[] { "tenant_id", "CustomerProfileId", "Label", "IsDefault" },
|
||||
unique: true,
|
||||
filter: "\"IsDefault\" = TRUE");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_contacts_tenant_id",
|
||||
table: "customer_contacts",
|
||||
column: "tenant_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_contacts_tenant_id_CustomerProfileId_Type",
|
||||
table: "customer_contacts",
|
||||
columns: new[] { "tenant_id", "CustomerProfileId", "Type" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ux_customer_contact_primary_per_type",
|
||||
table: "customer_contacts",
|
||||
columns: new[] { "tenant_id", "CustomerProfileId", "Type", "IsPrimary" },
|
||||
unique: true,
|
||||
filter: "\"IsPrimary\" = TRUE");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_profiles_tenant_id",
|
||||
table: "customer_profiles",
|
||||
column: "tenant_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_profiles_tenant_id_DisplayName",
|
||||
table: "customer_profiles",
|
||||
columns: new[] { "tenant_id", "DisplayName" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_tags_tenant_id",
|
||||
table: "customer_tags",
|
||||
column: "tenant_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_customer_tags_tenant_id_CustomerProfileId_Tag",
|
||||
table: "customer_tags",
|
||||
columns: new[] { "tenant_id", "CustomerProfileId", "Tag" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_organization_profiles_tenant_id",
|
||||
table: "organization_profiles",
|
||||
column: "tenant_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_organization_profiles_tenant_id_CustomerProfileId",
|
||||
table: "organization_profiles",
|
||||
columns: new[] { "tenant_id", "CustomerProfileId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_organization_profiles_tenant_id_TaxId13_BranchCode",
|
||||
table: "organization_profiles",
|
||||
columns: new[] { "tenant_id", "TaxId13", "BranchCode" },
|
||||
unique: true,
|
||||
filter: "\"TaxId13\" IS NOT NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_person_profiles_tenant_id",
|
||||
table: "person_profiles",
|
||||
column: "tenant_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_person_profiles_tenant_id_CustomerProfileId",
|
||||
table: "person_profiles",
|
||||
columns: new[] { "tenant_id", "CustomerProfileId" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "customer_addresses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "customer_contacts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "customer_tags");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "organization_profiles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "person_profiles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "addresses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "customer_profiles");
|
||||
}
|
||||
}
|
||||
}
|
||||
5789
AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.Designer.cs
generated
Normal file
5789
AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user