Several months ago, I was working late and needed to create a new column for a postgres table. I added the column through the command line using the standard heroku/postgres commands. I quickly realized how silly this was, deleted the column and then created the necessary migration to add it.
I recently took that laravel app and created a pipeline with it as the production app. I created a new staging app and set up a database for it. When I ran the migrations, I got an error saying that a column already existed. As you may have guessed, this is the same column that I had messed up before.
Since the migration failed after the database was created, I was able to delete the column in question, rerun the migration, and everything was OK. I do not understand why the column already existed except to guess that it was some artifact of my adding it manually (there was no error in the migrations).
I am worried that this same error will happen when I push the staging code to production and have to rerun my migrations. Obviously, in the production app I can't just delete the column in question as it has data.
Any ideas as to why this would happen and what I could do to fix the issue if it arises when I push the code into production?