package flyway.asdi;

import java.sql.Connection;
import java.util.List;

import org.flywaydb.core.api.migration.jdbc.JdbcMigration;

import fi.nls.oskari.db.BundleHelper;
import fi.nls.oskari.domain.map.view.Bundle;
import fi.nls.oskari.util.FlywayHelper;

public class V1_19_0__remove_asdi_guided_tour implements JdbcMigration {

	private static final String BUNDLE_NAME = "asdi-guided-tour";

	@Override
	public void migrate(Connection connection) throws Exception {

		Bundle bundle = new Bundle();
		bundle.setName(BUNDLE_NAME);

		final List<Long> views = FlywayHelper.getUserAndDefaultViewIds(connection);
		for (Long viewId : views) {
			if (FlywayHelper.viewContainsBundle(connection, BUNDLE_NAME, viewId)) {
				FlywayHelper.removeBundleFromView(connection, BUNDLE_NAME, viewId);
			}

		}
		BundleHelper.removeBundle(bundle, connection);
	}

}

@@ -169,53 +169,8 @@
 er;%0A
-import fi.nls.oskari.domain.map.view.Bundle;%0A
 impo
@@ -205,16 +205,16 @@
 Helper;%0A
+
 %0Apublic 
@@ -423,72 +423,8 @@
  %7B%0A%0A
-%09%09Bundle bundle = new Bundle();%0A%09%09bundle.setName(BUNDLE_NAME);%0A%0A
 %09%09fi
@@ -703,27 +703,36 @@
 per.
-removeBundle(bundle
+unregisterBundle(BUNDLE_NAME
 , co

Update helper method call to unregister bundle