rubenv / rubenv/sql-migrate

is it possible to create database on first migration?

Open
#134 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
3.4k
Forks
292
PR merge metrics
No merged PRs in 30d

Description

I guess it's not possible because the db every other migration should be run doesn't exist yet, but I'd like to know if there's some workaround or something

ideally, sql-migrate up would create the db and then run the rest of the migrations, and sql-migrate down -limit=0 would end up dropping the whole db.

Is it possible? Or is there a better way to do it? Or maybe it's just a bad idea?


I did a test, and sql-migrate ended up creating the migrations table on the master db (I'm using msssql), and the following migration failed because it couldn't find the migrations table

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sql-migrate up and sql-migrate down -limit=0 entry points and trace how the migrations table is created for MSSQL. Clarify whether database creation and full database removal are intended, then define and test the expected behavior before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
cli, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.