Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from SQLite to Postgres with Askar #1569

Open
niall-shaw opened this issue Sep 5, 2023 · 8 comments
Open

Migrate from SQLite to Postgres with Askar #1569

niall-shaw opened this issue Sep 5, 2023 · 8 comments

Comments

@niall-shaw
Copy link
Contributor

I thought this would be as simple as exporting the sqlite wallet, and importing into a postgres wallet.
But AskarWallet.ts has the following error:

throw new WalletError('Import is only supported for SQLite backend')

So a couple of questions:

  1. Why is importing not supported for Postgres, is it planned?
  2. How would one migrate from SQLite to Postgres without exporting/importing?
@niall-shaw
Copy link
Contributor Author

Related to openwallet-foundation/askar#58

@jakubkoci
Copy link
Contributor

I guess that it can be solved by exporting from SQLite and importing to Postgres, but I couldn't find any API for export/import.

@genaris
Copy link
Contributor

genaris commented Sep 5, 2023

At the time when we implemented initial Askar module, aries-askar did not include any feature to import/export stores natively, so our alternative was to just do the manual work of copying the entire database and re-keying the wallet.

However, now that openwallet-foundation/askar#159 has been merged, I think it should be possible to copy an entire store (or an individual profile) to another one. It might even be possible to switch between backends, which would be certainly promising.

I guess as soon as openwallet-foundation/askar#169 and openwallet-foundation/askar#170 are merged, a new release of Askar JS wrappers can be done and we could incorporate its enhancements to AskarWallet.

@TimoGlastra
Copy link
Contributor

Was already typing my reply, but you covered it pretty well @genaris :)

@niall-shaw
Copy link
Contributor Author

Thanks again for the prompt replies @genaris @TimoGlastra !

@DJHunn39
Copy link
Contributor

DJHunn39 commented Feb 9, 2024

@genaris @TimoGlastra with both of those PRs merged, has a new release of the Askar JS wrapper been made/has that been incorporated into the AskarWallet module?

I'm just trying to update storage for an agent on @aries-framework 0.4.x to @credo-ts 0.5.x (an alpha build, for now), but I'm running seeing these logs when attempting to auto update an agent using postgres for storage:

INFO: Starting update process. Total of 1 update(s) will be applied to update the agent storage from version 0.4 to version 0.5
FATAL: Error updating storage with updateIdentifier 1707408853441 because the wallet backend does not support exporting.
         Make sure to do a manual backup of your wallet and disable 'backupBeforeStorageUpdate' before proceeding.
    updateIdentifier: "1707408853441"
    error: {}

This is similar to the error from OP, but it's because export is also not supported for non-SQLite back ends.

@genaris
Copy link
Contributor

genaris commented Feb 9, 2024

@genaris @TimoGlastra with both of those PRs merged, has a new release of the Askar JS wrapper been made/has that been incorporated into the AskarWallet module?

I'm just trying to update storage for an agent on @aries-framework 0.4.x to @credo-ts 0.5.x (an alpha build, for now), but I'm running seeing these logs when attempting to auto update an agent using postgres for storage:

INFO: Starting update process. Total of 1 update(s) will be applied to update the agent storage from version 0.4 to version 0.5
FATAL: Error updating storage with updateIdentifier 1707408853441 because the wallet backend does not support exporting.
         Make sure to do a manual backup of your wallet and disable 'backupBeforeStorageUpdate' before proceeding.
    updateIdentifier: "1707408853441"
    error: {}

This is similar to the error from OP, but it's because export is also not supported for non-SQLite back ends.

In case of PosgreSQL wallets, it is possible to update but you'll need to explicitly set backupBeforeStorageUpdate to false in your Agent config.

It is of course recommended that you make a backup of your DB before doing any update using this setting.

@DJHunn39
Copy link
Contributor

@genaris @TimoGlastra with both of those PRs merged, has a new release of the Askar JS wrapper been made/has that been incorporated into the AskarWallet module?
I'm just trying to update storage for an agent on @aries-framework 0.4.x to @credo-ts 0.5.x (an alpha build, for now), but I'm running seeing these logs when attempting to auto update an agent using postgres for storage:

INFO: Starting update process. Total of 1 update(s) will be applied to update the agent storage from version 0.4 to version 0.5
FATAL: Error updating storage with updateIdentifier 1707408853441 because the wallet backend does not support exporting.
         Make sure to do a manual backup of your wallet and disable 'backupBeforeStorageUpdate' before proceeding.
    updateIdentifier: "1707408853441"
    error: {}

This is similar to the error from OP, but it's because export is also not supported for non-SQLite back ends.

In case of PosgreSQL wallets, it is possible to update but you'll need to explicitly set backupBeforeStorageUpdate to false in your Agent config.

It is of course recommended that you make a backup of your DB before doing any update using this setting.

That's true, and I can do that for now, but is there a plan to add auto backup support for Postgres backends?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants