luckyframework / luckyframework/avram

migrations: incorrectly attempting `drop :column` tries to drop a table with that name

Open
#889 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

In a migration I just tried this:

```crystal
def rollback
alter :domains do
drop :verification_token
drop :verification_status
end
end
```

And was greeted with this very confusing error message, which makes it seem like if I had a table called verification_token it might have been accidentally deleted. 👻

```
Error occurred while performing a migration.

Migration: AddDomainVerificationField::V20221007223200

Statements:
DROP TABLE verification_token
DROP TABLE verification_status (Avram::FailedMigration)
```

Contributor guide

Open the contributing guide

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 migration rollback shown in the issue and trace how `alter :domains` handles the two `drop` calls and assembles the failed-migration statements. Verify the resulting SQL and error output, with the goal that dropping columns does not appear as dropping tables.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.