Пример #1
0
        static int Main(string[] args)
        {
            try
            {
                Paths.InitializeRhetosServerRootPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".."));

                string connectionString = SqlUtility.ConnectionString;
                Console.WriteLine("SQL connection string: " + SqlUtility.MaskPassword(connectionString));
                var sqlExecuter = GetSqlExecuterImplementation(connectionString);

                var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), sqlExecuter);
                databaseCleaner.DeleteAllMigrationData();
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                DeploymentUtility.WriteError(ex.Message);
                Console.WriteLine("Details:");
                Console.WriteLine(ex);
                if (Environment.UserInteractive)
                {
                    Thread.Sleep(3000);
                }
                return(1);
            }
        }
Пример #2
0
        static int Main(string[] args)
        {
            try
            {
                var appRootFolder = AppDomain.CurrentDomain.BaseDirectory;
                var logProvider   = new ConsoleLogProvider();
                var host          = Host.Find(appRootFolder, logProvider);
                var configuration = host.RhetosRuntime.BuildConfiguration(logProvider, host.ConfigurationFolder,
                                                                          configurationBuilder => configurationBuilder.AddConfigurationManagerConfiguration());

                LegacyUtilities.Initialize(configuration);

                string connectionString = SqlUtility.ConnectionString;
                Console.WriteLine("SQL connection: " + SqlUtility.SqlConnectionInfo(connectionString));
                var sqlExecuter = GetSqlExecuterImplementation(connectionString);

                var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), sqlExecuter);
                databaseCleaner.DeleteAllMigrationData();
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine(ex);
                if (Environment.UserInteractive)
                {
                    Thread.Sleep(3000);
                }
                return(1);
            }
        }
Пример #3
0
        public void TestCleanupOldData(string description,
                                       string oldTables, string oldSchemas,
                                       string expectedDeletedTables, string expectedDeletedSchemas)
        {
            var mockSqlExecuter = new MockSqlExecuter("", oldTables, oldSchemas);
            var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), mockSqlExecuter);

            Console.WriteLine("Report: " + databaseCleaner.DeleteAllMigrationData());

            Assert.AreEqual("", TestUtility.DumpSorted(mockSqlExecuter.DroppedColumns), description + ": Deleted columns.");
            Assert.AreEqual(expectedDeletedTables, TestUtility.DumpSorted(mockSqlExecuter.DroppedTables), description + ": Deleted tables.");
            Assert.AreEqual(expectedDeletedSchemas, TestUtility.DumpSorted(mockSqlExecuter.DroppedSchemas), description + ": Deleted schemas.");
        }