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.

How to run a specific migration file?

See original GitHub issue

Is there a way to run a specific migration if I have multiple scripts living in my migrations/ folder? Lately, I have had a few use cases where I need to re-run a script whose entry is already in the fireway collection on Firestore. However, to actually make a script to be executed, I have found that I have to manually delete the entry corresponding to that script and others that came after it. For example, let’s say I have:

migrations/v0.0.1__first_migration.js migrations/v0.0.2__second_migration.js migrations/v0.0.3__third_migration.js

If I need to run just v0.0.2__second_migration.js, I have to delete both the corresponding v2 and v3 entries in the fireway collection and then rerun fireway migrate. Wouldn’t it be nice if I could do something like fireway migrate --script=v0.0.2?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kevlenedcommented, May 26, 2021

fireway only does roll-forward migrations

I understand, by the way what is the underlying reason for this current limitation? In any case, it’d be very nice if there was a way to do roll-backs, like alembic does. I know we’re not in SQL land here but I’m allowed to dream, right? 😄

I wouldn’t stop your dream! However, the NoSQL limitation is exactly the reason. I saw an idea for firestore migration rollbacks by @gregdingle, but I don’t plan on overhauling fireway for this flow.

There are times when I have had to rerun a migration because some older code was still being run, and it wrote data in the old schema/format.

Makes sense. To be successful in NoSQL, your client and server code needs to know how to handle multiple schemas (especially if you have mobile clients). You may be able to get around this with a fancy mapping of old to new properties on the server-side. Migrations don’t solve the problem unless you have downtime, because there’s no way to apply a migration atomically for large collections in firestore. In short, this is always going to be a problem, so your clients and server have to handle all old schemas until you’re certain there are no more old clients.

If you’re iterating on a migration, use --dryrun to ensure you don’t modify the production db.

At the moment --dryrun is not working for me - regardless of my use of it, the changes are being applied to the records but the fireway collection entry is not added. I am also impacted by this related issue

I haven’t been able to reproduce this problem. I would look for places that don’t use the firestore instance that fireway returns. This includes models you may be trying to share with your clients.

0reactions
kiptoommcommented, May 26, 2021

@kevlened any insights on the above questions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I run specific migration in laravel - Stack Overflow
This will undo the last migration/s. Then you can run php artisan migrate and all NOT migrated migrations will be migrated. If you...
Read more >
How can I run specific migration in laravel | Edureka Community
I create on address table migration but one migration is already in the database it gives following error :
Read more >
Migrations & Seeding - The PHP Framework For Web Artisans
Migrations are a type of version control for your database. They allow a team to modify the database schema and stay up to...
Read more >
Ho to execute a specific migration - Laracasts
You do this by simply inserting a row for each migration that you DONT want to run, and then set a batch number...
Read more >
Laravel Run Specific Migration - Scratch Code
To run the specific migration in Laravel, you need to use --path option with the php artisan migrate command. Let's take a simple...
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