Skip to content

Commit

Permalink
refactor: use db object, not cli args for Reger
Browse files Browse the repository at this point in the history
  • Loading branch information
kentbull committed Oct 10, 2024
1 parent 539647a commit b0ecf7e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/keri/app/cli/commands/migrate/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def recur(self, tyme):
pass

print(f"Migrating {self.args.name}...")
db.migrate(name=self.args.name, base=self.args.base, temp=self.args.temp)
db.migrate()
print(f"Finished migrating {self.args.name}")

return True
4 changes: 2 additions & 2 deletions src/keri/db/basing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ def reload(self):
for keys in removes: # remove bare .habs records
self.habs.rem(keys=keys)

def migrate(self, name, base, temp):
def migrate(self):
""" Run all migrations required
Run all migrations that are required from the current version of database up to the current version
Expand Down Expand Up @@ -1367,7 +1367,7 @@ def migrate(self, name, base, temp):

mod = importlib.import_module(modName)
try:
mod.migrate(self, name=name, base=base, temp=temp)
mod.migrate(self)
except Exception as e:
print(f"\nAbandoning migration {migration} at version {version} with error: {e}")
return
Expand Down
9 changes: 3 additions & 6 deletions src/keri/db/migrations/add_key_and_reg_state_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _check_if_needed(db):
return False
return True

def migrate(db, name, base, temp):
def migrate(db):
"""Adds schema for KeyStateRecord, RegStateRecord, and migrates the rgy.cancs., hby.db.pubs.,
and hby.db.digs. to be up to date as of 2022-??-??
This migration performs the following:
Expand All @@ -36,9 +36,6 @@ def migrate(db, name, base, temp):
Value: (prefix, sn) of each event
Parameters:
db(Baser): Baser database object on which to run the migration
name(str): name of the keystore
base(str): additional optional prefix to file location of KERI keystore
temp(bool): create a temporary keystore, used for testing
"""
# May be running on a database that is already in the right state yet has no migrations run
# so we need to check if the migration is needed
Expand Down Expand Up @@ -78,7 +75,7 @@ def migrate(db, name, base, temp):

nstates.pin(keys=keys, val=ksr)

rgy = viring.Reger(name=name, base=base, db=db, temp=temp, reopen=True)
rgy = viring.Reger(name=db.name, base=db.base, db=db, temp=db.temp, reopen=True)

rstates = koming.Komer(db=rgy,
schema=dict,
Expand Down Expand Up @@ -122,7 +119,7 @@ def migrate(db, name, base, temp):
db.qnfs.trim()

except ConfigurationError:
logger.error(f"identifier prefix for {name} does not exist, incept must be run first", )
logger.error(f"identifier prefix for {db.name} does not exist, incept must be run first", )
return -1


Expand Down
5 changes: 1 addition & 4 deletions src/keri/db/migrations/hab_data_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _check_if_needed(db):
return True
return False

def migrate(db, name, base, temp):
def migrate(db):
"""Rename data in HabitatRecord from the old labels to the new labels as of 2022-10-17
This migration performs the following:
Expand All @@ -71,9 +71,6 @@ def migrate(db, name, base, temp):
Parameters:
db(Baser): Baser database object on which to run the migration
name(str): name of the keystore
base(str): additional optional prefix to file location of KERI keystore
temp(bool): create a temporary keystore, used for testing
"""
# May be running on a database that is already in the right state yet has no migrations run
# so we need to check if the migration is needed
Expand Down
5 changes: 1 addition & 4 deletions src/keri/db/migrations/rekey_habs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _check_if_needed(db):
return False
return True

def migrate(db, name, base, temp):
def migrate(db):
""" Re-key habs migration for changing the key for .habs and introducing the .names database
This migrations performs the following:
Expand All @@ -47,9 +47,6 @@ def migrate(db, name, base, temp):
Parameters:
db(Baser): Baser database object on which to run the migration
name(str): name of the keystore
base(str): additional optional prefix to file location of KERI keystore
temp(bool): create a temporary keystore, used for testing
"""
# May be running on a database that is already in the right state yet has no migrations run
# so we need to check if the migration is needed
Expand Down

0 comments on commit b0ecf7e

Please sign in to comment.