Skip to content

Commit

Permalink
add bootstrap migration for adding key in attached file
Browse files Browse the repository at this point in the history
  • Loading branch information
geektortoise committed Nov 17, 2021
1 parent 27cb04a commit 96b621d
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ class BootstrapOldVersionService {
}


def initv3_2_1() {
log.info "Migration to V3.2.1"
new Sql(dataSource).executeUpdate("DROP VIEW user_image;")
bootstrapUtilsService.dropSqlColumn("abstract_image", "resolution")
bootstrapUtilsService.dropSqlColumn("image_instance", "resolution")
tableService.initTable()
}

def initv3_2_0() {
log.info "Migration to V3.2.0"
def sql = new Sql(dataSource)
Expand Down Expand Up @@ -535,6 +527,8 @@ class BootstrapOldVersionService {
// sql.executeUpdate("delete from abstract_image where id not in (select image_id from abstract_slice);")
sql.executeUpdate("UPDATE image_instance ii SET deleted = NOW() WHERE NOT EXISTS(SELECT 1 FROM slice_instance si WHERE si.image_id = ii.id);")
sql.executeUpdate("UPDATE abstract_image ai SET deleted = NOW() WHERE NOT EXISTS(SELECT 1 FROM abstract_slice asl WHERE asl.image_id = ai.id);")
bootstrapUtilsService.dropSqlColumn("abstract_image", "resolution")
bootstrapUtilsService.dropSqlColumn("image_instance", "resolution")

/****** COUNTERS ******/
log.info "Migration of counters"
Expand Down Expand Up @@ -593,6 +587,11 @@ class BootstrapOldVersionService {
// "and attached_file.domain_class_name = 'be.cytomine.project.Project';")


/****** ATTACHED FILE ******/
if (!bootstrapUtilsService.checkSqlColumnExistence("attached_file", "key")) {
new Sql(dataSource).executeUpdate("ALTER TABLE attached_file ADD COLUMN key VARCHAR;")
}

/****** VIEWS ******/
log.info "Regeneration of DB views"
sql.executeUpdate("DROP VIEW IF EXISTS user_image;")
Expand Down

0 comments on commit 96b621d

Please sign in to comment.