question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQLite + Delete.Column(): table column still there after migration

See original GitHub issue

This is very likely an issue with my usage, but I haven’t found any indication as to why in the docs or on forums. I have an SQLite database and the following migration:

[Migration(3)]
public class _003_add_surname_column : Migration
{
    public override void Up()
    {
        Rename.Column("name").OnTable("Test").To("forename");
        Alter.Table("Test").AddColumn("surname").AsString(50).Nullable();
    }

    public override void Down()
    {
        Delete.Column("surname").FromTable("Test");
        Rename.Column("forename").OnTable("Test").To("name");
    }
}

Migrating up works fine. Migrating down performs the column rename (from “forename” to “name”), but leaves the “surname” column in the table. I expected that column to be gone. Am I missing something? Or is that the intended behaviour?

Using FluentMigrator version 1.6.2, System.Data.SQLite.1.0.99.0, .NET 4.5.1.

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:25 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
fairkingcommented, May 17, 2021
2reactions
escarlscommented, Apr 22, 2018

I think for a start, FluentMigrator should probably throw and exception when an unsupported migration is run. Then for later, look at if it’s possible to do the workaround hacks with renaming table, create new table, copy data from old table.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sql - Drop column from SQLite table
Go to the tab, "Database Structure"; Select you table Select Modify table (just under the tabs); Select the column you want to delete;...
Read more >
Dropping Columns Like It's Hot
Following the steps above, let's try to drop the age column. First we'll rename the existing table into users_old , and create the...
Read more >
Overview of the SQL DELETE Column from an existing ...
Right-click on the column we want to remove and click on Delete as shown in the following image. SQL DELETE column using SSMS...
Read more >
ALTER TABLE
The DROP COLUMN syntax is used to remove an existing column from a table. ... The command is only successful if the schema...
Read more >
Fixing ALTER TABLE errors with Flask-Migrate and SQLite
With SQLite, however, the ALTER TABLE command only supports adding or renaming columns. ... (venv) $ flask db migrate -m "remove a column"....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found