Reputation: 13
I'm trying to generate a migration from a model using the command - "aqueduct db generate".
This is the model "request.dart" under lib > model (where i have the other models as well which were already migrated without any issues) :
import 'package:dbapi/dbapi.dart';
class Request extends ManagedObject<_Request> implements _Request {}
class _Request {
@managedPrimaryKey
int index;
String description;
}
It is however creating an empty migration because its not able to recognize the new model-"Request". Below is the output from "aqueduct db generate"
-- Aqueduct CLI Version: 2.5.0+1
-- Aqueduct project version: 2.5.0+1
-- Replaying migration files...
Replaying version 1
Replaying version 2
Replaying version 3
-- The following ManagedObject<T> subclasses were found:
Question
UserProfile
* If you were expecting more declarations, ensure the files are visible in the application library file.
-- Created new migration file (version 4).
note: The new model "request.dart" has the same file permissions as the previous models that I could migrate.
Has anyone else run into the same issue? Appreciate the help !
Upvotes: 1
Views: 466
Reputation: 511896
As Joe Conway said, I had to import the ManagedObject
subclass into my controller:
import 'package:my_project/model/my_model.dart';
After than running
aqueduct db generate
created the correct migration file. I was eventually going to use the managed object in the controller anyway, but I wasn't there yet and I wanted to generate the migration file first.
Upvotes: 0
Reputation: 1586
The file request.dart
has to be imported (directly or transitively) by your application's library file. In your case, this is dbapi.dart
.
But, it is unlikely that you would import request.dart
directly in your library file. Instead, your library file already imports your RequestSink
file, which must import any controller files used by the application, and those must import any models they use.
The likely scenario here is that you are not yet using this class in your code - once you start using it in a controller or service, it will be visible to the migration generation tool. Otherwise, you can just directly import it from your request sink file.
Upvotes: 3