Add entity address/contact tables and CRUD for entity resources

This commit is contained in:
seb
2026-08-06 05:43:50 +02:00
parent 0b7e40ac9c
commit 3b77a1c946
32 changed files with 3078 additions and 1363 deletions

View File

@@ -164,6 +164,38 @@ BEGIN
END
`;
export const INIT_ENTITYADDRESS = `
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'entityaddress')
BEGIN
CREATE TABLE entityaddress (
id INT IDENTITY(1,1) PRIMARY KEY,
entity_id INT NOT NULL,
first_name NVARCHAR(255) NULL,
name NVARCHAR(255) NULL,
street NVARCHAR(255) NULL,
streetnumber NVARCHAR(50) NULL,
zip NVARCHAR(50) NULL,
city NVARCHAR(255) NULL,
county NVARCHAR(255) NULL,
addresstype NVARCHAR(50) NOT NULL,
CONSTRAINT FK_entityaddress_entity FOREIGN KEY (entity_id) REFERENCES entity(id) ON DELETE CASCADE
);
END
`;
export const INIT_ENTITYCONTACT = `
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'entitycontact')
BEGIN
CREATE TABLE entitycontact (
id INT IDENTITY(1,1) PRIMARY KEY,
entity_id INT NOT NULL,
contacttype NVARCHAR(50) NOT NULL,
contact NVARCHAR(255) NOT NULL,
CONSTRAINT FK_entitycontact_entity FOREIGN KEY (entity_id) REFERENCES entity(id) ON DELETE CASCADE
);
END
`;
export const INIT_ENTITYHISTORY = `
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'entityhistory')
BEGIN
@@ -636,6 +668,8 @@ export const SCHEMA_SCRIPTS = [
INIT_CUSTOMERGROUP,
INIT_COMPANY_POS_CUSTOMERGROUP_FK,
INIT_ENTITY,
INIT_ENTITYADDRESS,
INIT_ENTITYCONTACT,
INIT_UNIT,
INIT_UNITTEXT,
INIT_OPTIONSLIST,