mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
Fix sql scripts
This commit is contained in:
@ -52,19 +52,42 @@ public class RerunableSqlTableJournal : SqlTableJournal
|
|||||||
|
|
||||||
protected string GetInsertJournalEntrySql(string @scriptName, string @applied, string @rerunable)
|
protected string GetInsertJournalEntrySql(string @scriptName, string @applied, string @rerunable)
|
||||||
{
|
{
|
||||||
return $"IF EXISTS (SELECT * FROM {FqSchemaTableName} WHERE Rerunable = 1 AND ScriptName ='{@scriptName}')" +
|
return $"IF EXISTS (SELECT * FROM {FqSchemaTableName} WHERE Rerunable = 1 AND ScriptName ='{@scriptName}') " +
|
||||||
"BEGIN" +
|
"BEGIN " +
|
||||||
$"UPDATE {FqSchemaTableName} SET Applied = {@applied}, Rerunable = {@rerunable} WHERE ScriptName = '{@scriptName}'" +
|
$"UPDATE {FqSchemaTableName} SET Applied = {@applied}, Rerunable = {@rerunable} WHERE ScriptName = '{@scriptName}' " +
|
||||||
"END" +
|
"END " +
|
||||||
"ELSE" +
|
"ELSE " +
|
||||||
"BEGIN" +
|
"BEGIN " +
|
||||||
$"insert into {FqSchemaTableName} (ScriptName, Applied, Rerunable) values ({@scriptName}, {@applied}, {@rerunable})" +
|
$"insert into {FqSchemaTableName} (ScriptName, Applied, Rerunable) values ({@scriptName}, {@applied}, {@rerunable}) " +
|
||||||
"END";
|
"END ";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetJournalEntriesSql()
|
protected override string GetJournalEntriesSql()
|
||||||
{
|
{
|
||||||
return $"select [ScriptName] from {FqSchemaTableName} where [Rerunable] = 0 order by [ScriptName]";
|
return @$"DECLARE @columnVariable AS NVARCHAR(max)
|
||||||
|
DECLARE @SQLString AS NVARCHAR(max)
|
||||||
|
|
||||||
|
|
||||||
|
SELECT @columnVariable =
|
||||||
|
CASE WHEN EXISTS
|
||||||
|
(
|
||||||
|
SELECT 1 FROM sys.columns WHERE Name = N'Rerunable' AND Object_ID = Object_ID(N'dbo.Migration')
|
||||||
|
)
|
||||||
|
THEN
|
||||||
|
(
|
||||||
|
'where [Rerunable] = 0'
|
||||||
|
)
|
||||||
|
ELSE
|
||||||
|
('')
|
||||||
|
END
|
||||||
|
|
||||||
|
PRINT @columnVariable
|
||||||
|
|
||||||
|
SET @SQLString = N'select [ScriptName] from dbo.Migration ' + @columnVariable + ' order by [ScriptName]'
|
||||||
|
|
||||||
|
PRINT @SQLString
|
||||||
|
|
||||||
|
EXECUTE sp_executesql @SQLString";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string CreateSchemaTableSql(string quotedPrimaryKeyName)
|
protected override string CreateSchemaTableSql(string quotedPrimaryKeyName)
|
||||||
|
Reference in New Issue
Block a user