-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 the doc for datasource migration #1547
Comments
@andenis I believe migrating models to postgreSQL works. Please make sure you run And if it still doesn't work we may need more detailed steps to help you reproduce the error. |
Hi @jannyHou, thanks for your help. |
@andenis You are right...The migration part is missing in LB4's datasource doc. If you don't mind, I would like to modify this issue's title to "Add the doc for datasource migration". And turn it to a doc story :) Acceptance criteria:
|
@jannyHou, yes modify this issue. I changed the title. |
@jannyHou , is it something we can provide here quickly? I'll see if we can put that in the Sept milestone. |
An outline how to write auto-update/auto-migrate script:
For longer term, we would like to implement (or enable our community to implement) a better migration tool that give more control to developers - see #487 |
@bajtos Thanks for pointing out the way migration can be done with I had a import {DbDataSource} from './datasources/db.datasource';
const db = new DbDataSource();
db.autoupdate('Todo', (err, result) => {
if (err) return console.log(err);
console.log(result);
}); I get the error:
Unsure how to proceed. Please provide some idea of how I can get the migrations to work. The 3.x version uses the JSON schema definition. How would it work with 4 version. |
I think something like that is missing:
instantiating the DefaultCrudRepository will setup the (juggler) model-definition and attach it to the provided datasource |
currently, I managed to migrate, but it seems cubersome
|
yes, attaching the model twice should no be required (first attached in the Repo-ctor) |
I think you have discovered a missing repository API. How about adding a new method to our Intended usage: const repo = new TodoRepository()
await repo.updateDatabaseSchema(); Implementation: updateDatabaseSchema(): Promise<void> {
return this.dataSource.autoupdate([
this.modelClass.modelName,
]);
} Personally, I'd much rather see a solution that will give more control to app developers, see the discussion in #487, but I think the proposal I have outlined here is a reasonable workaround for now. @raymondfeng @strongloop/sq-lb-apex thoughts? |
IMO, there will be two flavors of the migration apis:
We probably want to define a separate To test out the minimum viable feature, we can improve |
Could this please include the example TodoListRepository? I'm finding the Getter element confusing without an example. Thanks. |
@nabdelgadir , could you please take a look? After you've verified the working steps, can create a page in our docs. Thanks. |
this feature works?
Update by @jannyHou
Description
We are missing the datasource migration doc in loopback.io.
Acceptance criteria:
ds.automigrate() / ds.autoupdate()
and other datasource methods (include a list of what it is and what they do).The text was updated successfully, but these errors were encountered: