nafg / slick-migration-api

Schema manipulation dialects and DSL for Slick

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

idempotent add column

levinotik opened this issue · comments

Is there a way to make a migration only add columns if they don't already exist?

Hi. There isn't built in functionality per se, but you could extend
Migration directly, and put in code that only calls apply on the
TableMigration if the column doesn't exist.
I believe Slick has an API that lets you find that out (or you you could
use other means, like jdbc metadata API, or just isolate the addColumn
TableMigration and swallow exceptions in the wrapper Migration).

On Wed, Mar 18, 2015, 2:07 PM Levi Notik notifications@github.com wrote:

Is there a way to make a migration only add columns if they don't already
exist?

Reply to this email directly or view it on GitHub
#4.

Thanks a lot. One quick question: are there published artifacts somewhere that I can use in SBT? I tried using the maven one I saw in bintray..couldnt get it to work, but maybe I was doing something wrong.

Thanks a lot for this really useful project!

For now you have to add http://dl.bintray.com/naftoligug/maven/ as a custom maven resolver. I requested it be added to JCenter, BE"H that should happen soon. (Once that's done it could also get synced to maven central.)

When you've resolved it can you close the issue? Thanks.

Sure thing, thanks @nafg. I added that resolver and still couldn't get it right (i'm not very good at translating maven to sbt. What should the group % artifact % id look like? Thanks.

Do you see output from sbt indicating that it's trying to download http://dl.bintray.com/naftoligug/maven/io/github/nafg/slick-migration-api_2.11/0.1/slick-migration-api_2.11-0.1.jar?

For java (i.e. ordinary) artifacts, the syntax is

"group" % "artifact" % "version"

Scala artifacts use sbt's cross-scala-version artifact naming convention (the artifact name includes the scala version), which sbt will automatically add in if you use a %% instead of the first %.

The group id is "io.github.nafg", the artifact id is "slick-migration-api", and the version is "0.1".

Thanks a lot, the group id is what I had wrong!

@nafg I was able to switch to using the artifact instead of pulling it in directly from github. However, i get the following runtime error now:

scala.MatchError: java.lang.NoClassDefFoundError: scoverage/Invoker$ (of class java.lang.NoClassDefFoundError)

Any ideas on how I can fix this? Thanks!

I was able to resolve this by adding the plugin to my plugins.sbt, but I feel like I shouldn't need to do that to use the library.

I spoke too soon, I actually still have the MathError :(

Where/when is this error being triggered?

On Fri, Mar 20, 2015, 3:08 PM Levi Notik notifications@github.com wrote:

I spoke too soon, I actually still have the MathError :(

Reply to this email directly or view it on GitHub
#4 (comment)
.