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

requires migrationScripts to have a query #2

Closed
MrMoronIV opened this issue Aug 15, 2019 · 10 comments
Closed

requires migrationScripts to have a query #2

MrMoronIV opened this issue Aug 15, 2019 · 10 comments

Comments

@MrMoronIV
Copy link

Can this be made so the migrationScripts can just receive an empty List? Or an empty string in the list as the query?

It now assumes there's already a migration required but I was thinking ahead of possible required database changes in the future and now I need to provide a migration query like select 1

@esarbanis
Copy link
Contributor

Hi @MrMoronIV ,

I think you have a valid point. We should be able to tolerate empty migrationScripts

@esarbanis
Copy link
Contributor

Hm ... I have checked the code and we actually tolerate empty migrationScripts, check this test case to see how.

@MrMoronIV
Copy link
Author

How would you define the script then? As null or [] or ['']?

@esarbanis
Copy link
Contributor

According to the test case I mentioned above the MigrationConfig should have [] both in initializationScript and in migrationScripts.

Isn't the above behavior acceptable?

@esarbanis
Copy link
Contributor

OK, I now understand what is going on. I had put assertions in the MigrationConfig constructor and then I mocked it in the tests ... 🙄 .

I had the tests in place to allow the behavior you mentioned, but I was mocking MigrationConfig and thus its constructor was never called. So, I had passing tests that should have failed ...

I will remove the isEmpty assertions from MigrationConfig as well as the mock in the tests. Will release soon.

@esarbanis
Copy link
Contributor

esarbanis commented Aug 23, 2019

Issue fixed in v0.1.2

@MrMoronIV
Copy link
Author

Thank you, I'm glad I wasn't going insane despite my name :p

So putting [] as the migrationscript now works?

On another note but maybe unrelated, is there a way to reset the database so it gets recreated during testing or is that happening automatically when the app is built from scratch again (not just restarting)?

And secondly, am I correct if there is no way to inspect a database as if there was some sort of phpmyadmin?

@esarbanis
Copy link
Contributor

Yes, putting [] in migrationScripts will work from now own.

You can use the databaseExists and databaseDelete methods, before calling openDatabase, to always recreate the database.

You can try StackOverflow for your last question, I am not aware of any such tool.

@MrMoronIV
Copy link
Author

I don't want to spoil your tea but when I use [] for the migration script it says:

type 'List<dynamic>' is not a subtype of type 'List<String>'

My code

final migrations = [];

final config = MigrationConfig(
    initializationScript: initialScript, migrationScripts: migrations);

It says migrations is of type List<dynamic> and migrationScripts expects List<String>.
My pubspec.yaml sqflite_migration: ^0.1.2

@esarbanis
Copy link
Contributor

Try using a correctly typed list like <String>[].

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

2 participants