Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Migrations are pending" popup is too aggressive #540

Open
swanson opened this issue Dec 5, 2024 · 5 comments
Open

"Migrations are pending" popup is too aggressive #540

swanson opened this issue Dec 5, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@swanson
Copy link

swanson commented Dec 5, 2024

I often am running bin/rails g migration SomeMigration to get a blank migration and then writing it my editor instead of the generator. When I do this, the "Migrations are pending" popup immediately displays and asks me to run the (empty) migration.

From my perspective:

  • I would like this popup to ignore empty migrations that I just created
  • I would like the ability to disable this particular popup -- I wasn't able to find out how to do this in the list of "features enabled" in the main LSP

I think this has the potential for people to run the empty migration without realizing it ("I just click that button always") and then write the actual migration code and be confused why the changes don't seem to work (migration was marked as run so it doesnt re-run)

@andyw8 andyw8 added the enhancement New feature or request label Dec 5, 2024
@andyw8
Copy link
Contributor

andyw8 commented Dec 5, 2024

Hi Matt, thank you for the suggestion. We will consider some options for this.

@andyw8
Copy link
Contributor

andyw8 commented Dec 16, 2024

@swanson We discussed as a team and are considering this approach:

We won't prompt to run the migrations if the most recent migration is empty.

A migration would be considered empty if it has no methods:

class CreateFoo < ActiveRecord::Migration[8.0]
end

or if it contains only a timestamp column (which the generator may add by default).

class CreateFoo < ActiveRecord::Migration[8.0]
  def change
    create_table :foos do |t|
      t.timestamps
    end
  end
end

If were were do this, I don't think we wouldn't need an option to disable the popup.

The only downside I can think of is if you save the migration mid-way through writing it, then it would trigger the popup.

Any thoughts?

@swanson
Copy link
Author

swanson commented Dec 16, 2024

If I run bin/rails g migration ThisIsEmpty

the output is

class ThisIsEmpty < ActiveRecord::Migration[8.0]
  def change
  end
end

so I don't think that would solve my particular issue because the LSP would not consider that empty, correct?

@swanson
Copy link
Author

swanson commented Dec 16, 2024

Maybe "smart detection of empty migrations" is not the right solution, but it does seem like people (myself included) will want a way to turn off this popup, as it is pretty invasive if you aren't using it. The Rails "run pending migration" button is also an option so I don't believe this functionality is novel enough to be "always on".

@andyw8
Copy link
Contributor

andyw8 commented Dec 16, 2024

so I don't think that would solve my particular issue because the LSP would not consider that empty, correct?

We can have it treat that as empty too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants