本文整理汇总了Java中com.fsryan.forsuredb.api.migration.MigrationSet.containsMigrations方法的典型用法代码示例。如果您正苦于以下问题:Java MigrationSet.containsMigrations方法的具体用法?Java MigrationSet.containsMigrations怎么用?Java MigrationSet.containsMigrations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fsryan.forsuredb.api.migration.MigrationSet
的用法示例。
在下文中一共展示了MigrationSet.containsMigrations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateMigrationSql
import com.fsryan.forsuredb.api.migration.MigrationSet; //导入方法依赖的package包/类
@Override
public List<String> generateMigrationSql(MigrationSet migrationSet) {
if (migrationSet == null || !migrationSet.containsMigrations() || migrationSet.getTargetSchema() == null) {
return new ArrayList<>();
}
QueryGeneratorFactory qgf = new QueryGeneratorFactory(migrationSet);
List<Migration> migrations = migrationSet.getOrderedMigrations();
Collections.sort(migrations, new MigrationComparator(migrationSet.getTargetSchema()));
List<String> sqlList = new ArrayList<>();
Set<String> recreatedTables = new HashSet<>();
for (Migration m : migrations) {
if (recreatedTables.contains(m.getTableName()) && isMigrationHandledOnCreate(m, migrationSet.getTargetSchema())) {
continue;
}
if (TYPES_REQUIRING_TABLE_RECREATION.contains(m.getType())) {
recreatedTables.add(m.getTableName());
}
sqlList.addAll(qgf.getFor(m, migrationSet.getTargetSchema()).generate());
}
return sqlList;
}
示例2: createNewForeignKeyMap
import com.fsryan.forsuredb.api.migration.MigrationSet; //导入方法依赖的package包/类
/**
* <p>
* Foreign key migrations are difficult in that, in SQLite, they mist be added when the table is created.
* This is problematic because, if you have multiple foreign keys to add to the same table in one migration
* set, then you cannot know the correct temp table to create for temporary data storage simply by looking at
* the target context. You actually have to know all of the foreign key columns to add for a table prior to
* adding any foreign key column.
* </p>
* @param migrationSet the full set of migrations that this query generator factory is creating queries
* @return a map of tableName to list of column names that are new foreign keys
*/
private Map<String, List<String>> createNewForeignKeyMap(MigrationSet migrationSet) {
if (migrationSet == null || !migrationSet.containsMigrations() || migrationSet.getTargetSchema() == null) {
return Collections.emptyMap();
}
Map<String, List<String>> retMap = new HashMap<>();
for (Migration m : migrationSet.getOrderedMigrations()) {
if (m.getType() != Migration.Type.ADD_FOREIGN_KEY_REFERENCE) {
continue;
}
List<String> newForeignKeyColumns = retMap.get(m.getTableName());
if (newForeignKeyColumns == null) {
List<String> columnNames = new ArrayList<>();
columnNames.add(m.getColumnName());
retMap.put(m.getTableName(), columnNames);
} else {
newForeignKeyColumns.add(m.getColumnName());
}
}
return retMap;
}