Database/xyz/Constraints/083_xyz_asset_type_name_code_unique.sqladded
--liquibase formatted sql
--changeset agentneo:083_xyz_asset_type_name_code_unique runOnChange:true stripComments:true splitStatements:true endDelimiter:;
--comment: Unique name and code constraints for AssetType per project

----------------------------------------------------------------------------------------------------
-- Created by:  AgentNeo
-- Created on:  03/07/2026
-- Description: Enforces that AssetType Name and Code are each unique within a project. The API layer
--              maps a violation of these named constraints to a 409 Conflict.
----------------------------------------------------------------------------------------------------

ALTER TABLE xyz."AssetType" DROP CONSTRAINT IF EXISTS "AssetType_ProjectShardId_Name_key";
ALTER TABLE xyz."AssetType" ADD CONSTRAINT "AssetType_ProjectShardId_Name_key"
    UNIQUE ("ProjectShardId", "Name");

ALTER TABLE xyz."AssetType" DROP CONSTRAINT IF EXISTS "AssetType_ProjectShardId_Code_key";
ALTER TABLE xyz."AssetType" ADD CONSTRAINT "AssetType_ProjectShardId_Code_key"
    UNIQUE ("ProjectShardId", "Code");