Skip to content

Commit

Permalink
[1752] Fix SQLException while trying to update evolutions table for
Browse files Browse the repository at this point in the history
multi module support
  • Loading branch information
tazmaniax committed Nov 24, 2013
1 parent 6c95010 commit de87eaf
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions framework/src/play/db/Evolutions.java
@@ -1,9 +1,22 @@
package play.db;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.io.File;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Stack;

import org.apache.commons.lang.StringUtils;

import play.Logger;
import play.Play;
import play.PlayPlugin;
Expand All @@ -18,22 +31,6 @@
import play.mvc.results.Redirect;
import play.vfs.VirtualFile;

import java.io.File;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Stack;
import javax.sql.DataSource;

/**
* Handles migration of data.
*
Expand Down Expand Up @@ -604,16 +601,16 @@ private static void checkAndUpdateEvolutionsForMultiModuleSupport(Connection con
ResultSet rs = connection.getMetaData().getColumns(null, null, "play_evolutions", "module_key");

if(!rs.next()) {

System.out.println("!!! - Updating the play_evolutions table to cope with multiple modules - !!!");
execute("alter table play_evolutions add module_key varchar(255);");
execute("alter table play_evolutions drop primary key;");
execute("alter table play_evolutions add constraint pk_id_module_key primary key (id,module_key);");

System.out.println("!!! - Assigning any existing evolutions to the parent project - !!!");
PreparedStatement statement = connection.prepareStatement("update play_evolutions set module_key = ? where module_key is null");
statement.setString(1, Play.configuration.getProperty("application.name"));
statement.execute();

execute("alter table play_evolutions add constraint pk_id_module_key primary key (id,module_key);");
}
}

Expand Down

0 comments on commit de87eaf

Please sign in to comment.