Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Error on migration:rollback that should drop a column- Using Laravel Homestead & SQlite

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I'm getting an error on running "php artisan migrate:rollback" in Git Bash that should drop a column.

I've already ran:
1. composer require doctrine/dbal
2. composer update
3. I even tried "composer dump-autoload"

When I check on the database schema using: "sqlite3 database/database.sqlite" the table contains all the columns (including the one called "excerpt" which is the rogue one that should be dropped) but on running the rollback I get the error that the column isn't published. See below.

(Environment: laravel 5.3- Homestead, Gitbash, Sublime Text3, SQlite3)

The error is as follows:




My database schema is as follows:




The Migration that created the column is as follows:



How do you solve this so that you can seamlessly drop columns using migrate:rollback?
 
Mwaura Raymond
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I resorted to using a mysql database which runs flawlessly within the homestead virtual box. Just remember:

1. Log into the homestead box: "mysql -u homestead -p "   (enter "secret" when prompted for the password on the next line- it's masked)

2. Create your own database:  "create database your_database_name;"

and set this as the database name on your .env file, for example:





Oh. And when you create the articles migration, make a few changes as follows:

$table->timestamp("publishedat")->nullable();

//Notice I've added nullable to the defined timestamp, this will make the migration work otherwise you'll get the following error on running php artisan migrate





//Notice I've removed the underscore for published_at to read simply publishedat; this will save you a ton of grief when you get to the Eloquent stage, your Article object simply won't save(); and thus won't be committed to the database.


And if you're using Git Bash you can head over here "https://gist.github.com/hofmannsven/9164408" for some useful commands such as viewing your database tables and such.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!