@Override public void migrate(Handle handle, MigrationContext context) { handle.update("alter table session_attempts" + " add column index int"); } }
@Override public void migrate(Handle handle, MigrationContext context) { handle.update("alter table revisions" + " add column user_info text"); } }
/** * {@inheritDoc} */ @Override public Object value(Handle handle) { return handle.update(query, params); } });
private boolean doDelete(Handle h, String path) { return h.update("DELETE FROM filestore WHERE path=?", path) > 0; }
private boolean doDelete(Handle h, String path) { return h.update("DELETE FROM filestore WHERE path=?", path) > 0; }
public void createTables() { withTransaction(dbi -> { if(databaseKind == DatabaseKind.PostgreSQL) { dbi.update("CREATE TABLE jsondb (path VARCHAR COLLATE \"C\" PRIMARY KEY, value VARCHAR, kind INT, idx VARCHAR COLLATE \"C\")"); dbi.update("CREATE INDEX jsondb_idx ON jsondb (idx, value) WHERE idx IS NOT NULL"); } else { dbi.update("CREATE TABLE jsondb (path VARCHAR PRIMARY KEY, value VARCHAR, kind INT, idx VARCHAR)"); } }); }
@Override public void migrate(Handle handle, MigrationContext context) { // DatabaseProjectStoreManager.PgDao.getLatestActiveWorkflowDefinitions uses these indexes. handle.update("create index workflow_definitions_on_revision_id_and_id on workflow_definitions (revision_id, id)"); if (context.isPostgres()) { handle.update("create index projects_on_site_id_and_id on projects (site_id, id) where deleted_at is null"); } else { handle.update("create index projects_on_site_id_and_id on projects (site_id, id)"); } } }
@Override public void migrate(Handle handle, MigrationContext context) { if (context.isPostgres()) { // make sure records are unique handle.update("delete from secrets where id = any(select id from (select row_number() over (partition by site_id, project_id, scope, key order by id) as i, id from secrets) win where i > 1)"); } else { // h2 doesn't support window function... } handle.update("create unique index secrets_unique_on_site_id_and_project_id_and_scope_and_key on secrets (site_id, project_id, scope, key)"); handle.update("drop index secrets_on_site_id_and_project_id_and_scope_and_key"); } }
public void createTables() { withTransaction(dbi -> { if(databaseKind == DatabaseKind.PostgreSQL) { dbi.update("CREATE TABLE jsondb (path VARCHAR COLLATE \"C\" PRIMARY KEY, value VARCHAR, ovalue VARCHAR, idx VARCHAR COLLATE \"C\")"); dbi.update("CREATE INDEX jsondb_idx ON jsondb (idx, value) WHERE idx IS NOT NULL"); } else { dbi.update("CREATE TABLE jsondb (path VARCHAR PRIMARY KEY, value VARCHAR, ovalue VARCHAR, idx VARCHAR)"); } if( databaseKind == DatabaseKind.H2 ) { dbi.update("CREATE ALIAS IF NOT EXISTS split_part FOR \""+Strings.class.getName()+".splitPart\""); dbi.update("CREATE ALIAS IF NOT EXISTS trim_suffix FOR \""+Strings.class.getName()+".trimSuffix\""); } }); }
@Override public void migrate(Handle handle, MigrationContext context) { if (context.isPostgres()) { handle.update("alter table session_attempts" + " add column finished_at timestamp with time zone"); } else { handle.update("alter table session_attempts" + " add column finished_at timestamp"); } } }
@Override public void migrate(Handle handle, MigrationContext context) { // for DatabaseSessionStoreManager.findActiveAttemptsCreatedBefore. This includes all running attempts excepting CANCEL_REQUESTED (flag=0x01) if (context.isPostgres()) { handle.update("create index session_attempts_on_state_flags_and_created_at on session_attempts (created_at, id) where state_flags = 0"); } else { handle.update("create index session_attempts_on_state_flags_and_created_at on session_attempts (state_flags, created_at, id)"); } } }
/** * TODO: push this into the jsondb API. * * @param path * @param field */ private int deleteFieldsLT(String path, String field) { return dbi.inTransaction((conn, status) -> { StringBuilder sql = new StringBuilder("DELETE from jsondb where path LIKE ? and path < ?"); return conn.update(sql.toString(), path+"%", path + field); }); }
public void dropTables() { withTransaction(dbi -> { dbi.update("DROP TABLE jsondb"); }); }
public void dropTables() { withTransaction(dbi -> { dbi.update("DROP TABLE jsondb"); }); }
private int deleteJsonRecords(Handle dbi, String baseDBPath, String like) { Deque<String> params = getAllParentPaths(baseDBPath); StringBuilder sql = new StringBuilder("DELETE from jsondb where path LIKE ?"); if( !params.isEmpty() ) { sql.append(" OR path in ( ") .append(String.join(", ", Collections.nCopies(params.size(), "?"))) .append(" )"); } params.addFirst(like); return dbi.update(sql.toString(), params.toArray()); }
private int deleteJsonRecords(Handle dbi, String baseDBPath, String like) { Deque<String> params = getAllParentPaths(baseDBPath); StringBuilder sql = new StringBuilder("DELETE from jsondb where path LIKE ?"); if( !params.isEmpty() ) { sql.append(" OR path in ( ") .append(String.join(", ", Collections.nCopies(params.size(), "?"))) .append(" )"); } params.addFirst(like); return dbi.update(sql.toString(), params.toArray()); }
@Override public void migrate(Handle handle, MigrationContext context) { handle.update( context.newCreateTableBuilder("delayed_session_attempts") .addLongIdNoAutoIncrement("id", "references session_attempts (id)") .addLong("dependent_session_id", "") .addLong("next_run_time", "not null") .addTimestamp("updated_at", "not null") .build()); handle.update("create index delayed_session_attempts_on_next_run_time on delayed_session_attempts (next_run_time)"); } }
private void createSchemaMigrationsTable(Handle handle, MigrationContext context) { handle.update( context.newCreateTableBuilder("schema_migrations") .addString("name", "not null") .addTimestamp("created_at", "not null") .build()); }