question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create a schema through the FluentMigrator method

See original GitHub issue

Hey there,

I was testing the fluent migrator and was unable to create a schema when using the Create.Schema("test_db"); method. I was only able to overcome that when actually pointing a script to be executed.

Is that a known issue?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zendevercommented, Mar 16, 2016

@blacksagres …So, in MySQL, as I’m sure you’re aware, treats SCHEMA and DATABASE as synonymous. So, in theory, creating the schema/database in a migration would be possible as long as, the connecting user has the privilege and the migration is not part of a session that has an active table lock (which might be automatically triggered in a transaction). Have you tried to specify the non-transactional attribute on the migration?

Now, I’ll be honest, FluentMigrator CAN do these things, but there has been discussion around the true purpose of migration and which schema/database would “own” the migration. Part of the challenge is that migration has to be tracked somewhere, and typically, if you’re migrating a database, then the migration should be tracked on the target schema/database. This gets tricky when spinning up a database because without a VersionInfo table to check against, the migrator wouldn’t know whether or not the script was run. To get around this, you can obviously connect to a different schema/database, run the script that creates the database, and then in a different transaction, run the rest of the migration against the actual target, but you can see how this might lead to issues down the road (conceptually) since the migration to create the schema/database will be tracked against another schema/database that really isn’t the target.

That being said, I do wonder if there should be a “create if not exists” feature that is run only in the even that the target database doesn’t exist…but that would mean finding a way to do a connection without an initial schema/database…it’s something to think about, for sure.

I hope this sheds a little light on the issue.

0reactions
marcrocnycommented, Mar 6, 2017

@blacksagres, would be helpful to understand whether this is really a requirement or just a misunderstanding about the schema-database identity in MySQL. If the former, please change the title of the issue to reflect that this is a requirement for creating a new database via FM; if the latter, please close the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Easy Schema Migrations in .NET Core | by Manfred Lange
Using Fluent Migrator to maintain database schemas; Writing and applying database schema migrations; A Database class to keep things simple ...
Read more >
FAQ | FluentMigrator documentation
If you get ORA-00900: Invalid SQL Statement when executing a stored procedure, then chances are you need to wrap your stored procedure in...
Read more >
Fluent Interface | FluentMigrator documentation
The FM fluent api allows you to create tables, columns, indexes and (nearly) every construct you need to manipulate your database structure.
Read more >
Schema, table and column names processing via custom ...
I'm writing a migration tool for modular applications which are intended to use internal modules, each with its own set of migrations.
Read more >
How I use Fluent Migrator
The idea with Fluent Migrator is to create a series of classes that create and modify the database schema (and data).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found