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

add database versioning and migration to docs #155

Closed
alidcastano opened this issue Jul 5, 2019 · 2 comments
Closed

add database versioning and migration to docs #155

alidcastano opened this issue Jul 5, 2019 · 2 comments
Labels

Comments

@alidcastano
Copy link

@alidcastano alidcastano commented Jul 5, 2019

creating this issue as a placeholder / temporary reference

from gitter channel:

version is a number representing the current database version.

onVersionUpdate is a function that is passed the current version and should return the migrated version.

 nSQL().createDatabase({
    id: “my-db”,
    tables: […],
    version: 3,
    onVersionUpdate: (prevVersion) => {
         return new Promise((res, rej) => {
             switch(prevVersion) {
                 case 1:
                     // migrate v1 to v2
                    res(2);
                    break;
                 case 2:
                     // migrate v2 to v3
                     res(3);
                     break;
             }

         });

     }
@alidcastano

This comment has been minimized.

Copy link
Author

@alidcastano alidcastano commented Jul 5, 2019

also thinking that it might be more useful to have versioning for tables (rather than the top-level databases) since table data is what gets migrated

that's at least what I need for my project since I'm autoloading most of the logic based on table entities, and so I was planning to do the same for versioning/migration - but I imagine this could be built on top of the existing setup so going to play around with it and see

ClickSimply pushed a commit that referenced this issue Jul 21, 2019
@ClickSimply

This comment has been minimized.

Copy link
Owner

@ClickSimply ClickSimply commented Jul 23, 2019

Migration docs are live on this page: https://nanosql.io/databases.html#creating-a-database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.