IF NOT EXISTS (
    SELECT 1
    FROM sys.objects
    WHERE object_id = OBJECT_ID(N'[dbo].[asr_bas_crn_depth_rule]')
      AND type = N'U'
)
BEGIN
    CREATE TABLE [dbo].[asr_bas_crn_depth_rule] (
        [id] BIGINT IDENTITY(1,1) NOT NULL,
        [whs_type] INT NOT NULL,
        [crn_no] INT NOT NULL,
        [layout_type] INT NOT NULL,
        [search_rows_csv] VARCHAR(255) NULL,
        [shallow_rows_csv] VARCHAR(255) NULL,
        [deep_rows_csv] VARCHAR(255) NULL,
        [enabled] INT NOT NULL CONSTRAINT [DF_asr_bas_crn_depth_rule_enabled] DEFAULT ((1)),
        [memo] VARCHAR(255) NULL,
        [create_by] BIGINT NULL,
        [create_time] DATETIME NULL,
        [update_by] BIGINT NULL,
        [update_time] DATETIME NULL,
        CONSTRAINT [PK_asr_bas_crn_depth_rule] PRIMARY KEY CLUSTERED ([id] ASC),
        CONSTRAINT [UK_asr_bas_crn_depth_rule_whs_crn] UNIQUE NONCLUSTERED ([whs_type] ASC, [crn_no] ASC)
    );

    EXEC sys.sp_addextendedproperty
        @name = N'MS_Description', @value = N'堆垛机深浅库位规则',
        @level0type = N'SCHEMA', @level0name = N'dbo',
        @level1type = N'TABLE',  @level1name = N'asr_bas_crn_depth_rule';
END;
