Пример #1
0
 protected static string SaveDataMigrationScriptEntiry(DataMigrationScript script)
 {
     return(string.Format(
                "INSERT INTO Rhetos.DataMigrationScript (Tag, Path, Content) VALUES ({0}, {1}, {2})",
                SqlUtility.QuoteText(script.Tag),
                SqlUtility.QuoteText(script.Path),
                SqlUtility.QuoteText(script.Content)));
 }
Пример #2
0
 protected static string SaveDataMigrationScriptMetadata(DataMigrationScript script)
 {
     return(string.Format(
                "DELETE FROM Rhetos.DataMigrationScript WHERE Active = 0 AND Tag = {0};\r\n"
                + "INSERT INTO Rhetos.DataMigrationScript (Tag, Path, Content, Active) VALUES ({0}, {1}, {2}, 1);",
                SqlUtility.QuoteText(script.Tag),
                SqlUtility.QuoteText(script.Path),
                SqlUtility.QuoteText(script.Content)));
 }
Пример #3
0
        private IEnumerable <SqlTransactionBatches.SqlScript> UpdateMetadata(DataMigrationScript script)
        {
            string updateMetadata = $"UPDATE Rhetos.DataMigrationScript SET Down = {SqlUtility.QuoteText(script.Down)}" +
                                    $" WHERE Tag = {SqlUtility.QuoteText(script.Tag)};";

            yield return(new SqlTransactionBatches.SqlScript {
                Sql = updateMetadata, IsBatch = false, Name = null
            });
        }
Пример #4
0
        private IEnumerable <SqlBatchScript> RemoveScriptAndMetadata(DataMigrationScript script)
        {
            string removeMetadata = $"UPDATE Rhetos.DataMigrationScript SET Active = 0 WHERE Tag = {SqlUtility.QuoteText(script.Tag)};";

            if (!string.IsNullOrEmpty(script.Down))
            {
                yield return new SqlBatchScript {
                           Sql = script.Down, IsBatch = true, Name = script.Path
                }
            }
            ;
            yield return(new SqlBatchScript {
                Sql = removeMetadata, IsBatch = false, Name = null
            });
        }
Пример #5
0
        private IEnumerable <SqlTransactionBatches.SqlScript> AddScriptAndMetadata(DataMigrationScript script)
        {
            string addMetadata = string.Format(
                "DELETE FROM Rhetos.DataMigrationScript WHERE Active = 0 AND Tag = {0};\r\n"
                + "INSERT INTO Rhetos.DataMigrationScript (Tag, Path, Content, Down, Active) VALUES ({0}, {1}, {2}, {3}, 1);",
                SqlUtility.QuoteText(script.Tag),
                SqlUtility.QuoteText(script.Path),
                SqlUtility.QuoteText(script.Content),
                SqlUtility.QuoteText(script.Down));

            yield return(new SqlTransactionBatches.SqlScript {
                Sql = script.Content, IsBatch = true, Name = script.Path
            });

            yield return(new SqlTransactionBatches.SqlScript {
                Sql = addMetadata, IsBatch = false, Name = null
            });
        }
Пример #6
0
 protected void LogScript(string msg, DataMigrationScript script, EventType eventType = EventType.Trace)
 {
     _logger.Write(eventType, () => msg + " " + script.Path + " (tag " + script.Tag + ")");
 }