public static void setOrder(SQLBase base) { Set<String> tableNames = base.getTableNames(); for (String tableName : tableNames) { SQLTable table = base.getTable(tableName); // SQLField fieldPrimaryKey = table.getKey(); SQLField field = table.getOrderField(); if (field != null) { base.execute( "ALTER TABLE \"" + tableName + "\" ALTER COLUMN \"" + field.getName() + "\" SET DEFAULT 0;"); base.execute( "ALTER TABLE \"" + tableName + "\" ALTER COLUMN \"" + field.getName() + "\" SET NOT NULL;"); } } }
public static void addUndefined(SQLBase base) { Set<String> tableNames = base.getTableNames(); for (String tableName : tableNames) { SQLTable table = base.getTable(tableName); SQLField fieldPrimaryKey = table.getKey(); if (fieldPrimaryKey != null && fieldPrimaryKey.getType().getJavaType().getSuperclass() != null && fieldPrimaryKey.getType().getJavaType().getSuperclass() == Number.class) { String patch = "INSERT INTO \"" + tableName + "\"(\"" + fieldPrimaryKey.getName() + "\") VALUES (1)"; base.execute(patch); } } }