예제 #1
0
 /// <summary>
 /// Runs the migrations.
 /// </summary>
 public static void Migrate(CommandLineParams parameters)
 {
     using (Migrator migrator = MigratorFactory.CreateMigrator(parameters.config))
     {
         migrator.Migrate(parameters.version);
     }
 }
예제 #2
0
 public static void Initialize(CommandLineParams parameters)
 {
     using (Migrator migrator = MigratorFactory.CreateMigrator(parameters.config))
     {
         migrator.Initialize();
     }
 }
예제 #3
0
        /// <summary>
        /// Show usage information and help.
        /// </summary>
        public static void PrintUsage(CommandLineParams parameters)
        {
            const int TAB = 20;

            Console.WriteLine("usage:\nECM7.Migrator.Console.exe provider connectionString migrationsAssembly [options]");
            Console.WriteLine();
            Console.WriteLine("\t{0} {1}", "provider".PadRight(TAB), "Provider alias or full name of provider type (include assembly name)");
            Console.WriteLine("\t{0} {1}", "connectionString".PadRight(TAB), "Connection string to the database");
            Console.WriteLine("\t{0} {1}", "migrationAssembly".PadRight(TAB), "Path to the assembly containing the migrations");
            Console.WriteLine("Options:");
            parameters.options.WriteOptionDescriptions(Console.Out);

            Console.WriteLine();
        }
예제 #4
0
        /// <summary>
        /// Выводит текущий список миграций
        /// </summary>
        public static void List(CommandLineParams parameters)
        {
            using (Migrator mig = MigratorFactory.CreateMigrator(parameters.config))
            {
                IList<long> appliedMigrations = mig.GetAppliedMigrations();

                Console.WriteLine("Available migrations:");
                foreach (var info in mig.AvailableMigrations)
                {
                    long v = info.Version;
                    Console.WriteLine(
                        "{0} {1} {2}",
                        appliedMigrations.Contains(v) ? "=>" : "  ",
                        v.ToString().PadLeft(3),
                        StringUtils.ToHumanName(info.Type.Name));
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Выводит текущий список миграций
        /// </summary>
        public static void List(CommandLineParams parameters)
        {
            using (Migrator mig = MigratorFactory.CreateMigrator(parameters.config))
            {
                IList <long> appliedMigrations = mig.GetAppliedMigrations();

                Console.WriteLine("Available migrations:");
                foreach (var info in mig.AvailableMigrations)
                {
                    long v = info.Version;
                    Console.WriteLine(
                        "{0} {1} {2}",
                        appliedMigrations.Contains(v) ? "=>" : "  ",
                        v.ToString().PadLeft(3),
                        StringUtils.ToHumanName(info.Type.Name));
                }
            }
        }
예제 #6
0
        public static int Main(string[] args)
        {
            try
            {
                WriteHeader();

                var parameters = CommandLineParams.Parse(args);

                ConfigureLogging();

                switch (parameters.mode)
                {
                case MigratorConsoleMode.Migrate:
                    Migrate(parameters);
                    break;

                case MigratorConsoleMode.List:
                    List(parameters);
                    break;

                case MigratorConsoleMode.Initialize:
                    Initialize(parameters);
                    break;

                case MigratorConsoleMode.Help:
                    PrintUsage(parameters);
                    break;
                }

                return(0);
            }
            catch (Exception exception)
            {
                Exception baseException = exception.GetBaseException();

                Console.WriteLine(baseException.Message);

                Console.WriteLine(baseException.StackTrace);

                Console.WriteLine("Try `ECM7.Migrator.Console --help' for more information");

                return(-1);
            }
        }
예제 #7
0
 /// <summary>
 /// Runs the migrations.
 /// </summary>
 public static void Migrate(CommandLineParams parameters)
 {
     using (Migrator migrator = MigratorFactory.CreateMigrator(parameters.config))
     {
         migrator.Migrate(parameters.version);
     }
 }
예제 #8
0
        /// <summary>
        /// Show usage information and help.
        /// </summary>
        public static void PrintUsage(CommandLineParams parameters)
        {
            const int TAB = 20;

            Console.WriteLine("usage:\nECM7.Migrator.Console.exe provider connectionString migrationsAssembly [options]");
            Console.WriteLine();
            Console.WriteLine("\t{0} {1}", "provider".PadRight(TAB), "Provider alias or full name of provider type (include assembly name)");
            Console.WriteLine("\t{0} {1}", "connectionString".PadRight(TAB), "Connection string to the database");
            Console.WriteLine("\t{0} {1}", "migrationAssembly".PadRight(TAB), "Path to the assembly containing the migrations");
            Console.WriteLine("Options:");
            parameters.options.WriteOptionDescriptions(Console.Out);

            Console.WriteLine();
        }