コード例 #1
0
        // private const String MYSQL_DB = "mysql";
        #endregion

        #region Methods
        /// <summary>
        /// Determines the type of database we're configured to use and returns the appropriate connection
        /// object
        /// </summary>
        /// <returns></returns>
      

        public DbConnection getConnection()
        {
            /*
             * Determine the type of database we're configured to use
             */
            log.Debug("Getting configuration information from ConfigurationManager");
            MigrationConfigurationManager configMgr = new MigrationConfigurationManager();
            DBConfiguration dbConfig = configMgr.getDBConfiguration();
            
            /*
             * Determine the type of DB
             */
            if (dbConfig.DatabaseType == ORACLE_DB)
            {
                return getOracleConnection(dbConfig);
            }
            
                return getSQLConnection(dbConfig);
            
           
            //TODO: throw exception if configured for a different database type


        }
コード例 #2
0
		/// <summary> Loads the configuration from the migration config properties file.
		/// 
		/// </summary>
		/// <param name="launcher">the launcher to configure
		/// </param>
		/// <param name="systemName">the name of the system
		/// </param>
		/// <throws>  MigrationException if an unexpected error occurs </throws>
		private void  configureFromMigrationProperties(AdoMigrationLauncher launcher, System.String systemName)
		{
            MigrationConfigurationManager configMgr = new MigrationConfigurationManager();
            DBConfiguration dbConfig = configMgr.getDBConfiguration();
            MigrationConfiguration migrationConfig = configMgr.getMigrationConfiguration();

            launcher.PatchPath = migrationConfig.PatchPath;
            launcher.PostPatchPath = migrationConfig.PostPatchPath;

            DataSourceMigrationContext context = DataSourceMigrationContext;
            System.String databaseType = dbConfig.DatabaseType;
            context.DatabaseType = new DatabaseType(databaseType);
            
            // Finish setting up the context
            context.SystemName = systemName;

            //context.DataSource = dataSource;

            // done reading in config, set launcher's context
            launcher.AddContext(context);
        }
コード例 #3
0
        /// <summary>
        /// 
        /// </summary>
        public override void initialize()
        {
            try
            {
                //TODO: must create way to get System name from configuration.
                MigrationConfigurationManager configMgr = new MigrationConfigurationManager();
                MigrationConfiguration migrationConfig = configMgr.getMigrationConfiguration();

                // The MigrationLauncher is responsible for handling the interaction
                // between the PatchTable and the underlying MigrationTasks; as each
                // task is executed, the patch level is incremented, etc.
                try
                {
                    AdoMigrationLauncherFactory launcherFactory = AdoMigrationLauncherFactoryLoader.createFactory();
                    AdoMigrationLauncher launcher = launcherFactory.createMigrationLauncher(migrationConfig.SystemName);
                    launcher.DoMigrations();
                    //firstRun = false;
                }
                catch (MigrationException e)
                {
                    // Runtime exceptions coming from a ServletContextListener prevent the
                    // application from being deployed.  In this case, the intention is
                    // for migration-enabled applications to fail-fast if there are any
                    // errors during migration.
                    throw new ApplicationException("Migration exception caught during migration", e);
                }
            }
            catch (System.SystemException e)
            {
                // Catch all exceptions for the sole reason of logging in
                // as many places as possible - debugging migration
                // problems requires detection first, and that means
                // getting the word of failures out.
                log.Error(e.StackTrace);

                System.Console.Out.WriteLine(e.Message);

                System.Console.Error.WriteLine(e.Message);

                throw e;
            }
        }
コード例 #4
0
        public static void Main(System.String[] arguments)
        {
            MigrationConfigurationManager configMgr = new MigrationConfigurationManager();
            MigrationConfiguration migrationConfig = configMgr.getMigrationConfiguration();

            String systemName = migrationConfig.SystemName;
            // The MigrationLauncher is responsible for handling the interaction
            // between the PatchTable and the underlying MigrationTasks; as each
            // task is executed, the patch level is incremented, etc.
            try
            {
                AdoMigrationLauncherFactory launcherFactory = AdoMigrationLauncherFactoryLoader.createFactory();
                AdoMigrationLauncher launcher = launcherFactory.createMigrationLauncher(systemName);
                launcher.DoMigrations();
            }
            catch (System.Exception e)
            {
                log.Error(e);
                throw e;
            }
        }