Database Tables not Created

I ran into the same issue:
I have different schemas in my database and datasources.
Ignition created historian tables only for the first datasource and not for the others. And historian is throwing errors because the tables are not there.

I worked around it by manually adding the tables in the schemas and adding a trigger that would add the tables partitions whenever ignition adds a line in the “sqlth_partitions” table…

CREATE OR ALTER TRIGGER tai_qlt_sqlth_partitions ON SCADA.qlt.sqlth_partitions
AFTER INSERT
AS
BEGIN
DECLARE @tablename NVARCHAR(100)
SET @tablename = (SELECT TOP 1 pname FROM INSERTED )
DECLARE @insert_query NVARCHAR(MAX);
SET @insert_query =CONCAT(N'CREATE TABLE SCADA.qlt.', @tablename,' (
		tagid int NOT NULL,
		intvalue bigint NULL,
		floatvalue float NULL,
		stringvalue nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
		datevalue datetime NULL,
		dataintegrity int NULL,
		t_stamp bigint NOT NULL,
		CONSTRAINT PK__sqlt_dat__', @tablename,' PRIMARY KEY (tagid,t_stamp)
	)
 	CREATE NONCLUSTERED INDEX ', @tablename,'t_stampndx ON qlt.', @tablename,' (  t_stamp ASC  )  
	WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ')
EXEC sp_executesql @insert_query
END```