<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Abd El-latif</title>
    <description>The latest articles on Forem by Abd El-latif (@a_abdellatif).</description>
    <link>https://forem.com/a_abdellatif</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F240171%2Fa5388af8-9907-49bd-9ec5-11b99234d300.jpg</url>
      <title>Forem: Abd El-latif</title>
      <link>https://forem.com/a_abdellatif</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/a_abdellatif"/>
    <language>en</language>
    <item>
      <title>Tired of Rails one-off scripts becoming a nightmare? I built something for that.</title>
      <dc:creator>Abd El-latif</dc:creator>
      <pubDate>Mon, 17 Nov 2025 21:51:23 +0000</pubDate>
      <link>https://forem.com/a_abdellatif/tired-of-rails-one-off-scripts-becoming-a-nightmare-i-built-something-for-that-5fcb</link>
      <guid>https://forem.com/a_abdellatif/tired-of-rails-one-off-scripts-becoming-a-nightmare-i-built-something-for-that-5fcb</guid>
      <description>&lt;p&gt;You know the drill. You need to run a script once to fix some data, update user preferences, or migrate something. You write a rake task, run it, and then... did it actually run? Did it work? If something breaks halfway through, how do you know where to restart?&lt;/p&gt;

&lt;p&gt;I got tired of this cycle, so I built &lt;strong&gt;script_tracker&lt;/strong&gt; - a Ruby gem that treats your one-off scripts like migrations (but better).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tracks which scripts have run (no more "did I run this already?")&lt;/li&gt;
&lt;li&gt;Wraps everything in transactions (rollback on failure)
&lt;/li&gt;
&lt;li&gt;Built-in progress logging ("Processing 1,247 of 10,000 users...")&lt;/li&gt;
&lt;li&gt;Batch processing helpers (because memory matters)&lt;/li&gt;
&lt;li&gt;Timeout support (no more runaway scripts)&lt;/li&gt;
&lt;li&gt;Simple rake commands to manage everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Some random rake task&lt;/span&gt;
&lt;span class="c1"&gt;# Did this run? Who knows!&lt;/span&gt;
&lt;span class="n"&gt;rake&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="ss"&gt;:fix_user_preferences&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Clean, tracked, logged&lt;/span&gt;
&lt;span class="n"&gt;rake&lt;/span&gt; &lt;span class="n"&gt;scripts&lt;/span&gt;&lt;span class="ss"&gt;:create&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"fix user preferences"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; 
&lt;span class="n"&gt;rake&lt;/span&gt; &lt;span class="n"&gt;scripts&lt;/span&gt;&lt;span class="ss"&gt;:run&lt;/span&gt;
&lt;span class="n"&gt;rake&lt;/span&gt; &lt;span class="n"&gt;scripts&lt;/span&gt;&lt;span class="ss"&gt;:status&lt;/span&gt;  &lt;span class="c1"&gt;# See what ran and when&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The best part? If your script fails halfway through, you know exactly where, and you can handle retries properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why I built this:&lt;/strong&gt;&lt;br&gt;
Data scripts have burned every Rails dev. When you run something in production, it fails silently, or worse, it runs twice and corrupts the data. I wanted the same confidence we have with migrations, but for one-off scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real talk:&lt;/strong&gt; This started as internal tooling at my company. We had too many “wait, did that script run?” conversations. Now our data migrations are as reliable as our schema migrations.&lt;/p&gt;

&lt;p&gt;The gem is open source and ready to use. Would love feedback from fellow Rails developers who’ve felt this pain.&lt;/p&gt;

&lt;p&gt;Check it out: &lt;a href="https://github.com/a-abdellatif98/script_tracker" rel="noopener noreferrer"&gt;https://github.com/a-abdellatif98/script_tracker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What’s your biggest one-off script horror story? I bet this would have prevented it.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
    </item>
  </channel>
</rss>
