create database via FM?

2,044 views
Skip to first unread message

Justin Collum

unread,
Apr 1, 2011, 2:12:41 PM4/1/11
to FluentMigrator Google Group
Working through my first project still, nearly there, but discovered
that I'll need to create the database. Seems odd. I can create
everything else within the database, but not the database itself. Am I
missing something? Is this a feature that people would like to see? Is
it too hard to implement?

Working with SQL Server 2008.

Specifically I'm thinking of a first deploy to a server. Would I have
to run a script against [master] before I run the rest of my scripts?
Would FM choke beecause of the connection string?

Justin Collum

unread,
Apr 1, 2011, 2:20:23 PM4/1/11
to FluentMigrator Google Group
I thought about using Execute.WithConnection, but I can't find any
tests for that method in the tests. Or any samples of how to use it.

Jeff Treuting

unread,
Apr 1, 2011, 2:22:41 PM4/1/11
to fluentmigrato...@googlegroups.com
Right now there is no Create.Database(), not sure if there are technical issues with it or not, but seems like something that could be added.  You should add it as a suggestion on the github issues tracker.

I've always just created them in the DB first.  But if you need/want to create it in the code then you could always use Execute.Sql() and pass it your create sql syntax.

Jeff

--
You received this message because you are subscribed to the Google Groups "FluentMigrator Google Group" group.
To post to this group, send email to fluentmigrato...@googlegroups.com.
To unsubscribe from this group, send email to fluentmigrator-goog...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentmigrator-google-group?hl=en.




--
Jeff Treuting
Truburn Solutions, LLC
(206) 393-0717
www.truburn.net
je...@truburn.net



Jeff Treuting

unread,
Apr 1, 2011, 2:25:18 PM4/1/11
to fluentmigrato...@googlegroups.com
Sorry, I just read your first message now and didn't really think through the technical part.

The technical problem is going to be the connection string.  You will need that to be for your specific DB so that would be the hurdle.

Personally, I would just create the DB manually then do all your migrations via code.

--
You received this message because you are subscribed to the Google Groups "FluentMigrator Google Group" group.
To post to this group, send email to fluentmigrato...@googlegroups.com.
To unsubscribe from this group, send email to fluentmigrator-goog...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluentmigrator-google-group?hl=en.

Justin Collum

unread,
Apr 1, 2011, 4:09:14 PM4/1/11
to FluentMigrator Google Group
You're right, that connection string seems like an issue. Wonder if
there'd be a cross-platform way to do a DropAndCreate command by
connecting to the master database... I'm thinking of a "drop it if
exists, then create new one" command.
> *Jeff Treuting*
> Truburn Solutions, LLC
> (206) 393-0717www.truburn.net
> j...@truburn.net

Justin Collum

unread,
Apr 1, 2011, 6:31:57 PM4/1/11
to FluentMigrator Google Group
I investigated this a bit more and decided creating the database via
FM was a bad idea. Specifically because the Create Database command
needs to know where to store its files (the .mdf files in the case of
SQL Server). Doing that automatically seems like it'll just cause
problems or just not work.

Sean Chambers

unread,
Apr 2, 2011, 11:27:59 AM4/2/11
to fluentmigrato...@googlegroups.com
I create a database through a nant script and sqlcmd since I use sql server.

I can provide an example if you'd like. I came across this before and determined that this really wasnt a concern of FM and complicates how FM works with the migrations.

Sean
Reply all
Reply to author
Forward
0 new messages