public static void main(String[] args) {

		String action = args[0];

		Properties props = new Properties();
		try {
			props.load(new FileInputStream(new File("migrator.properties")));
		} catch (FileNotFoundException e) {
			throw new RuntimeException(
					"No migrator.properties file found.  Make sure it's in the same dir as the jar file.",
					e);
		} catch (IOException e) {
			throw new RuntimeException(
					"Can't read migrator.properties file.  Make sure it's readable.", e);
		}

		String driver = props.getProperty("db.driver");
		String url = props.getProperty("db.url");
		String user = props.getProperty("db.username");
		String password = props.getProperty("db.password");
		String scripts = props.getProperty("migration.scripts.are.in");

		Migrator migrator = new Migrator(url, driver, user, password, scripts);

		if (action != null) {

			if (action.equals("upgrade")) {
				System.out.println("upgrade action started");
				migrator.migrateUp();
				System.out.println("\nupgrade action ended");
			} else if (action.equals("upgrade-all")) {
				System.out.println("upgrade-all action started");
				migrator.migrateUpAll();
				System.out.println("\nupgrade-all action ended");
			} else if (action.equals("rollback")) {
				System.out.println("rollback action started");
				migrator.migrateDown();
				System.out.println("\nrollback action ended");
			} else if (action.equals("init")) {
				System.out.println("init action started");
				migrator.initDb();
				System.out.println("\ninit action ended");
			} else if (action.equals("status")) {
				System.out.println("status action started");
				migrator.printAfterDiagnostics();
				System.out.println("\nstatus action ended");
			} else {
				throw new IllegalArgumentException("don't kow what " + action
						+ " is.  Must be one of: upgrade-all upgrade rollback init status");
			}

		}
	}