Skip to content

print to console F# code for migrations when the app runs in library mode #36

Open
@AngelMunoz

Description

Is your feature request related to a problem? Please describe.
When you are running migrations in the following format

#r "nuget: Migrondi.Core, 1.0.0-beta-009"

open System
open System.IO
open Migrondi.Core

let config = MigrondiConfig.Default

let migrondi = Migrondi.MigrondiFactory(config, ".")

migrondi.Initialize()

migrondi.RunNew(
  "add-test-table",
  "create table if not exists test (id int not null primary key);",
  "drop table if exists test;"
)

let applied = migrondi.DryRunUp()

printfn
  $"List of the migrations that would have been ran:\n\n%A{applied}"

You pass the migration content but is up to the developer to come up with a name and a timestamp for this, moreover this timestamp has to be part of the name we have a bug there as well

Describe the solution you'd like

When the migrondi new my-thing command is ran, adding the following flags would help

migrondi new new-migration --print --lang F#

// Use this code as a template for your next migration
migrondi.RunNew(
  "new-migration_00000000",
  "-- apply new content",
  "-- rollback content"
)

should be printed in the console, specifying --lang sql should generate a normal migrondi migration file

migrondi new new-migration --print --lang sql

-- MIGRONDI:NAME=new-migration_00000000.sql
-- MIGRONDI:TIMESTAMP=00000000
-- ---------- MIGRONDI:UP ----------
-- add new sql here

-- ---------- MIGRONDI:DOWN ----------
-- rollback here

Describe alternatives you've considered
This is more of a quality-of-life update for those who might want to run this as a separate project but is not actually required.

Additional context
N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions