viewFieldsFrag := 'startDate , startDateS , startDateSM , startDateSW , startDateSD , startDateSH , endDate, endDateS , endDateSM , endDateSW , endDateSD , endDateSH ';
viewQuerySQLiteFrag := 'startDate , strftime(''%Y-%m-%d %H:%M:%S'', startDate) , strftime(''%Y-%m'', startDate) , strftime(''%Y-%W'', startDate) , strftime(''%Y-%m-%d'', startDate) , strftime(''%Y-%m-%d %H'', startDate) , endDate, strftime(''%Y-%m-%d %H:%M:%S'', endDate) , strftime(''%Y-%m'', endDate) , strftime(''%Y-%W'', endDate) , strftime(''%Y-%m-%d'', endDate) , strftime(''%Y-%m-%d %H'', endDate) ';
viewQueryPostgreSQLFrag := 'startDate , to_char(startDate, ''YYYY-MM-DD HH24:MI:SS'') , to_char(startDate, ''YYYY-MM'') , to_char(startDate, ''YYYY-WW'') , to_char(startDate, ''YYYY-MM-DD'') , to_char(startDate, ''YYYY-MM-DD HH24'') , endDate, to_char(endDate, ''YYYY-MM-DD HH24:MI:SS'') , to_char(endDate, ''YYYY-MM'') , to_char(endDate, ''YYYY-WW'') , to_char(endDate, ''YYYY-MM-DD'') , to_char(endDate, ''YYYY-MM-DD HH24'') ';
viewQuerySQLServerFrag := 'startDate , format(startDate, ''yyyy-MM-dd hh:mm:ss'', ''en-US'') , format(startDate, ''yyyy-MM'', ''en-US'') , concat(format(startDate, ''yyyy-'', ''en-US''), cast(datepart(iso_week, startDate) as varchar(2))) , format(startDate, ''yyyy-MM-dd'', ''en-US'') , format(startDate, ''yyyy-MM-dd hh'', ''en-US'') , endDate, format(endDate, ''yyyy-MM-dd hh:mm:ss'', ''en-US''), format(endDate, ''yyyy-MM'', ''en-US''), concat(format(endDate, ''yyyy-'', ''en-US''), cast(datepart(iso_week, startDate) as varchar(2))), format(endDate, ''yyyy-MM-dd'', ''en-US''), format(endDate, ''yyyy-MM-dd hh'', ''en-US'')';
{%REGION 'V1101_RepCache_PowerOns' /fold}
dbo := TDBObjectsEnum.dbo__V1101_RepCache_PowerOns;
BlankTLiquibaseCreationScriptsDBDependent(lqds);
lqds[TMEPLiquibaseDatabaseType.ldtSQLite] := '<createView fullDefinition="true" viewName="V1101_RepCache_PowerOns">' + LineEnding
+ 'create view V1101_RepCache_PowerOns(machine , id, ' + viewFieldsFrag + ', durationSeconds, durationMinutes , durationHours , totalEnergyWh, totalEnergykWh )' + LineEnding
+ ' as select refMachine, id, ' + viewQuerySQLiteFrag + ', durationSeconds, durationSeconds/60 , durationSeconds/3600, totalEnergyWh, totalEnergyWh / 1000 from T1101_RepCache_PowerOns' + LineEnding
+ '</createView>' + LineEnding;
lqds[TMEPLiquibaseDatabaseType.ldtPostgreSQL] := '<createView fullDefinition="true" viewName="V1101_RepCache_PowerOns">' + LineEnding
+ 'create view V1101_RepCache_PowerOns(machine , id, ' + viewFieldsFrag + ' , durationSeconds, durationMinutes , durationHours , totalEnergyWh, totalEnergykWh )' + LineEnding
+ ' as select refMachine, id, ' + viewQueryPostgreSQLFrag + ', durationSeconds, durationSeconds/60, durationSeconds/3600, totalEnergyWh, totalEnergyWh/1000 from T1101_RepCache_PowerOns' + LineEnding
+ '</createView>' + LineEnding;
lqds[TMEPLiquibaseDatabaseType.ldtSQLServer] := '<createView fullDefinition="true" viewName="V1101_RepCache_PowerOns">' + LineEnding
+ 'create view V1101_RepCache_PowerOns(machine , id, ' + viewFieldsFrag + ' , durationSeconds, durationMinutes , durationHours , totalEnergyWh, totalEnergykWh )' + LineEnding
+ ' as select refMachine, id, ' + viewQuerySQLServerFrag + ', durationSeconds, durationSeconds/60, durationSeconds/3600, totalEnergyWh, totalEnergyWh/1000 from T1101_RepCache_PowerOns' + LineEnding
+ '</createView>' + LineEnding;
DBObjectDescriptors[dbo] := TDBObjectDescriptor.CreateView({Name}'V1101_RepCache_PowerOns',
{CreateScript} 'create view V1101_RepCache_PowerOns '
+ '( '
+ ' machine , id, startDateS , startDateSD , startDateSH , endDateS , endDateSD , endDateSH , durationSeconds, durationMinutes , durationHours , totalEnergyWh, totalEnergykWh '
+ ') '
+ 'as '
+ ' select refMachine , id, strftime(''%Y-%m-%d %H:%M:%S'', startDate), strftime(''%Y-%m-%d'', startDate), strftime(''%Y-%m-%d %H'', startDate), strftime(''%Y-%m-%d %H:%M:%S'', endDate), strftime(''%Y-%m-%d'', endDate), strftime(''%Y-%m-%d %H'', endDate), durationSeconds, durationSeconds/60 , durationSeconds/3600, totalEnergyWh, totalEnergyWh / 1000'
+ ' from T1101_RepCache_PowerOns',
{LiquibaseCreateDBSpecifci}lqds,
{DropScript}'drop view V1101_RepCache_PowerOns');
{%ENDREGION}