当前位置: 首页>>代码示例>>Java>>正文


Java MigrationSet类代码示例

本文整理汇总了Java中com.fsryan.forsuredb.api.migration.MigrationSet的典型用法代码示例。如果您正苦于以下问题:Java MigrationSet类的具体用法?Java MigrationSet怎么用?Java MigrationSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MigrationSet类属于com.fsryan.forsuredb.api.migration包,在下文中一共展示了MigrationSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:ryansgot,项目名称:forsuredbsqlitelib,代码行数:24,代码来源:SqlGenerator.java

示例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;
}
 
开发者ID:ryansgot,项目名称:forsuredbsqlitelib,代码行数:34,代码来源:QueryGeneratorFactory.java

示例3: TwoMigrationSetTest

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
public TwoMigrationSetTest(List<Migration> firstMigrations,
                           Map<String, TableInfo> firstExpectedSchema,
                           List<Migration> secondMigrations,
                           Map<String, TableInfo> secondExpectedSchema) {
    super(Arrays.asList(MigrationSet.builder()
                    .orderedMigrations(firstMigrations)
                    .dbVersion(1)
                    .targetSchema(firstExpectedSchema)
                    .build(),
            MigrationSet.builder()
                    .orderedMigrations(secondMigrations)
                    .dbVersion(2)
                    .targetSchema(secondExpectedSchema)
                    .build()),
            2,
            secondExpectedSchema);
}
 
开发者ID:ryansgot,项目名称:forsuredbcompiler,代码行数:18,代码来源:MigrationContextTest.java

示例4: getMigrationSets

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
/**
 * @return a sorted list of Migration
 */
public List<MigrationSet> getMigrationSets() {
    if (migrationSets == null) {
        createMigrationSets();
    }
    return migrationSets;
}
 
开发者ID:ryansgot,项目名称:forsuredbandroid,代码行数:10,代码来源:Migrator.java

示例5: FSDBHelper

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
private FSDBHelper(Context context, String dbName, List<FSTableCreator> tables, List<MigrationSet> migrationSets, boolean debugMode) {
    super(context, dbName, cursorFactory, identifyDbVersion(migrationSets));
    this.context = context;
    this.tables = tables;
    this.migrationSets = migrationSets;
    this.debugMode = debugMode;
}
 
开发者ID:ryansgot,项目名称:forsuredbandroid,代码行数:8,代码来源:FSDBHelper.java

示例6: identifyDbVersion

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
/**
 * @param migrationSets The {@link List} of {@link Migration}
 * @return either 1 or the largest dbVersion in the migrationSets list
 */
private static int identifyDbVersion(List<MigrationSet> migrationSets) {
    if (migrationSets == null || migrationSets.size() == 0) {
        return 1;
    }

    int version = 1;
    for (MigrationSet migrationSet : migrationSets) {
        version = migrationSet.getDbVersion() > version ? migrationSet.getDbVersion() : version;
    }
    return version;
}
 
开发者ID:ryansgot,项目名称:forsuredbandroid,代码行数:16,代码来源:FSDBHelper.java

示例7: applyMigrations

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
private void applyMigrations(SQLiteDatabase db, int previousVersion) {
    for (MigrationSet migrationSet : migrationSets) {
        if (previousVersion >= migrationSet.getDbVersion()) {
            continue;
        }
        executeSqlList(db, Sql.generator().generateMigrationSql(migrationSet), "performing migration sql: ");
    }
}
 
开发者ID:ryansgot,项目名称:forsuredbandroid,代码行数:9,代码来源:FSDBHelper.java

示例8: getCode

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
@Override
protected String getCode() {
    MigrationSet migrationSet = new DiffGenerator(new MigrationContext(mr), mr.latestDbVersion()).analyzeDiff(pContext);
    APLog.i(LOG_TAG, "Number of migrations in set = " + migrationSet.getOrderedMigrations().size());
    if (migrationSet.getOrderedMigrations().size() == 0) {
        return null;
    }

    return new Gson().toJson(migrationSet);
}
 
开发者ID:ryansgot,项目名称:forsuredbcompiler,代码行数:11,代码来源:MigrationGenerator.java

示例9: analyzeDiff

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
/**
 * <p>
 *     Anayzes the diff between this instance's {@link TableContext TableContext} and that of
 *     the argument
 * </p>
 * @param targetContext The {@link TableContext TableContext} that you would like to reach from
 *                      the {@link TableContext TableContext} member of this
 *                      {@link DiffGenerator DiffGenerator}
 * @return a priority queue of {@link Migration} that describes a sequence of migrations to
 * apply to migrate a database from the schema of this instance's {@link TableContext} to that
 * of the {@link TableContext TableContext} argument.
 */
public MigrationSet analyzeDiff(TableContext targetContext) {
    APLog.i(LOG_TAG, "analyzing diff: targetContext.allTables().size() = " + targetContext.allTables().size());

    PriorityQueue<Migration> migrationQueue = new PriorityQueue<>();
    migrationQueue.addAll(additiveChanges(targetContext));
    migrationQueue.addAll(subtractiveChanges(targetContext));

    return MigrationSet.builder().dbVersion(sourceDbVersion + 1)
            .orderedMigrations(toList(migrationQueue))
            .targetSchema(targetContext.tableMap())
            .build();
}
 
开发者ID:ryansgot,项目名称:forsuredbcompiler,代码行数:25,代码来源:DiffGenerator.java

示例10: OneMigrationSetTest

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
public OneMigrationSetTest(List<Migration> migrations, Map<String, TableInfo> expectedSchema) {
    super(Arrays.asList(MigrationSet.builder()
            .orderedMigrations(migrations)
            .dbVersion(1)
            .targetSchema(expectedSchema)
            .build()),1, expectedSchema);
}
 
开发者ID:ryansgot,项目名称:forsuredbcompiler,代码行数:8,代码来源:MigrationContextTest.java

示例11: QueryGeneratorFactory

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
public QueryGeneratorFactory(MigrationSet migrationSet) {
    newForeignKeyColumnMap = createNewForeignKeyMap(migrationSet);
}
 
开发者ID:ryansgot,项目名称:forsuredbsqlitelib,代码行数:4,代码来源:QueryGeneratorFactory.java

示例12: setUp

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
@Before
public void setUp() {
    MigrationSet migrationSet = new Gson().fromJson(inputMigrationJson, MigrationSet.class);
    actualSqlOutput = new SqlGenerator().generateMigrationSql(migrationSet);
}
 
开发者ID:ryansgot,项目名称:forsuredbsqlitelib,代码行数:6,代码来源:MigrationSqlQueryTest.java

示例13: MigrationContextTest

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
public MigrationContextTest(List<MigrationSet> input, int latestDbVersion, Map<String, TableInfo> expectedSchema) {
    this.input = input;
    this.latestDbVersion = latestDbVersion;
    this.expectedSchema = expectedSchema;
}
 
开发者ID:ryansgot,项目名称:forsuredbcompiler,代码行数:6,代码来源:MigrationContextTest.java

示例14: SmallDiffGeneratorTest

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
public SmallDiffGeneratorTest(int sourceDbVersion, TableContext migrationContext, TableContext processingContext, MigrationSet expectedMigrationSet) {
    super(sourceDbVersion, migrationContext, processingContext, expectedMigrationSet);
}
 
开发者ID:ryansgot,项目名称:forsuredbcompiler,代码行数:4,代码来源:SmallDiffGeneratorTest.java

示例15: BaseDiffGeneratorTest

import com.fsryan.forsuredb.api.migration.MigrationSet; //导入依赖的package包/类
public BaseDiffGeneratorTest(int sourceDbVersion, TableContext migrationContext, TableContext processingContext, MigrationSet expectedMigrationSet) {
    this.sourceDbVersion = sourceDbVersion;
    this.migrationContext = migrationContext;
    this.processingContext = processingContext;
    this.expectedMigrationSet = expectedMigrationSet;
}
 
开发者ID:ryansgot,项目名称:forsuredbcompiler,代码行数:7,代码来源:BaseDiffGeneratorTest.java


注:本文中的com.fsryan.forsuredb.api.migration.MigrationSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。