Coder Social home page Coder Social logo

Comments (8)

ragnard avatar ragnard commented on May 29, 2024

I think having the migrations be plain SQL files is very valuable. It means I can open them in my editor, edit the contents in the best way my editor can provide, get syntax highlightning, helpful formattting, maybe completion when connected to a database, execute statements line-by-line REPL style, etc. As soon as we stuff SQL text in a string we lose all that.

Have you considered the option of allowing multiple files per up/down migration, executed as separate commands in order by some sequence identifier? For example:

20120903221323-add-test-table.up.1.sql
20120903221323-add-test-table.up.2.sql
20120903221323-add-test-table.up.3.sql

from ragtime.

weavejester avatar weavejester commented on May 29, 2024

That's an interesting suggestion. Perhaps the syntax can be determined from the filename. So:

  • \.edn$
  • \.(up|down)\.sql$
  • \.(up|down)\.\d+\.sql$

The reason I might still keep the edn syntax is that it's more concise and needs little code. Additionally, if a multimethod is used based on the file extension, other formats can be supported.

from ragtime.

ragnard avatar ragnard commented on May 29, 2024

I'm all for supporting different formats, I appreciate my views are biased by my particular workflow etc so having this open to extension (with EDN and sql in the box) would be great.

Not exactly sure what the extension point would look like. Might be a challenge to just dispatch on extension as the SQL format with multiple files per migration would need to consider a set of files and order them. But I don't know what the logic for loading files currently looks like.

from ragtime.

weavejester avatar weavejester commented on May 29, 2024

We just take a list of files, group them by extension, and then send each group to a multimethod.

from ragtime.

timvisher avatar timvisher commented on May 29, 2024

I generally stick to one statement per file and just use the normal sequencing method to get this behavior. What's the intrinsic value in providing multiple statements in a file?

from ragtime.

weavejester avatar weavejester commented on May 29, 2024

Grouping statements allows the migration to be considered atomically. If one statement fails, the whole migration fails.

from ragtime.

timvisher avatar timvisher commented on May 29, 2024

Ah. Yeah that makes sense. I guess I haven't been doing much DML with ragtime yet. That use case wasn't in my head.

from ragtime.

weavejester avatar weavejester commented on May 29, 2024

Done (99edc4c).

from ragtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.