예제 #1
0
 private static List<String> cat(
     List<? extends ChangeTable<?>> cts, final String r, final boolean forceCat) {
   final List<String> res = new ArrayList<String>();
   for (final ConcatStep step : ConcatStep.values()) {
     for (final ChangeTable<?> ct : cts) {
       final String asString = ct.asString(r, step);
       if (asString != null && asString.length() > 0) {
         res.add(asString);
       }
     }
   }
   // don't return [""] because the caller might test the size of the result and assume that
   // the DB was changed
   // MySQL needs to have its "alter table add/drop fk" in separate execute()
   // (multiple add would work in 5.0)
   if (!forceCat && (cts.size() == 0 || cts.get(0).getSyntax().getSystem() == SQLSystem.MYSQL))
     return res;
   else return Collections.singletonList(CollectionUtils.join(res, "\n"));
 }
예제 #2
0
 @SuppressWarnings("unchecked")
 protected T mutateTo(ChangeTable<?> ct) {
   if (this.getSyntax() != ct.getSyntax())
     throw new IllegalArgumentException(
         "not same syntax: " + this.getSyntax() + " != " + ct.getSyntax());
   this.setName(ct.getName());
   for (final Entry<ClauseType, Collection<String>> e : ct.clauses.entrySet()) {
     for (final String s : e.getValue()) this.addClause(s, e.getKey());
   }
   for (final DeferredClause c : ct.inClauses.values()) {
     this.addClause(c);
   }
   for (final DeferredClause c : ct.outClauses.values()) {
     this.addOutsideClause(c);
   }
   for (final Object[] fk : ct.fks) {
     // don't create index, it is already added in outside clause
     this.addForeignConstraint((List<String>) fk[0], (SQLName) fk[1], false, (List<String>) fk[2]);
   }
   return thisAsT();
 }