Revision 53921
Added by Tsampikos Livisianos over 4 years ago
modules/uoa-stats-service/trunk/src/main/java/eu/dnetlib/data/statsmanager/StatsManager.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import javax.sql.DataSource; |
12 | 12 |
import java.sql.Connection; |
13 |
import java.sql.ResultSet; |
|
13 | 14 |
import java.util.HashMap; |
14 | 15 |
import java.util.Map; |
15 | 16 |
|
... | ... | |
44 | 45 |
Connection con = dataSource.getConnection(); |
45 | 46 |
|
46 | 47 |
log.info("Backing up and Replacing public schema with shadow in " + dataSource.getConnection().getMetaData().getURL() + " ..."); |
47 |
con.createStatement().execute("drop schema if exists backup CASCADE ;"); |
|
48 |
con.createStatement().execute("alter schema public rename to backup ;"); |
|
49 |
//con.createStatement().execute("drop schema if exists public CASCADE ;"); |
|
50 |
con.createStatement().execute("alter schema shadow rename TO public ;"); |
|
51 |
log.info("All ops done!"); |
|
48 |
ResultSet rs = con.createStatement().executeQuery("select schema_name from information_schema.schemata where schema_name='shadow';"); |
|
49 |
if(rs.next()) { |
|
50 |
con.createStatement().execute("drop schema if exists backup CASCADE ;"); |
|
51 |
con.createStatement().execute("alter schema public rename to backup ;"); |
|
52 |
con.createStatement().execute("alter schema shadow rename TO public ;"); |
|
53 |
log.info("All ops done!"); |
|
54 |
} |
|
52 | 55 |
con.close(); |
53 | 56 |
} |
54 | 57 |
|
... | ... | |
65 | 68 |
executeCommand(job.getAction(), job.getParameters()); |
66 | 69 |
} else if (job.getAction().equals("promoteShadow")) { |
67 | 70 |
|
68 |
executeCommand("promoteAll", job.getParameters()); |
|
71 |
if(job.getParameters().get("cache") != null && !job.getParameters().get("cache").contains("production")) { |
|
72 |
executeCommand("promoteAll", job.getParameters()); |
|
73 |
} |
|
69 | 74 |
this.promoteShadowSchema(); |
70 | 75 |
|
71 | 76 |
} else if (job.getAction().equals("promoteNums")) { |
Also available in: Unified diff
make production not re-promoteAll