How do I convince SSDT to stop creating a clustered index on the table when I just want to create a clustered columnstore index?
This looks like a bug in SSDT database projects for the edge case where the first column in the table cannot be indexed. Workarounds I can think of are:
- reorder the table columns such that the first column is indexable
- comment out the create index in the source code and include an idempotent index create in a post-deployment script
Below is an example of the second option:
--table create source code:
CREATE TABLE [Fact].[EcommGeomappedNew] (
[Col1] VARCHAR (MAX) NOT NULL,
[Col2] int NOT NULL
);
GO
/*
NOTE: idempotent columnstore index create included in post-deployment script to work-around SSDT bug (17.0.62201.12090)
CREATE CLUSTERED COLUMNSTORE INDEX [egni]
ON [Fact].[EcommGeomappedNew]
GO
*/
--post-deployment script
IF NOT EXISTS(SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'Fact.EcommGeomappedNew') AND type_desc = N'CLUSTERED COLUMNSTORE')
BEGIN
PRINT 'Creating CLUSTERED COLUMNSTORE INDEX on Fact.EcommGeomappedNew...';
CREATE CLUSTERED COLUMNSTORE INDEX [egni]
ON [Fact].[EcommGeomappedNew];
END;
GO