I generated a scaffold and put in the type:value but now I need to add another field / db column how do I add another type:value without destroying and restarting my whole project?
rake aborted!
Mysql::Error: You have an error in your SQL syntax; check the manual that corres
ponds to your MySQL server version for the right syntax to use near '(11), `titl
e` varchar(255) DEFAULT NULL, `artist_old` varchar(255) DEFAULT NULL,' at line 1
: CREATE TABLE `albums` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY(11
), `title` varchar(255) DEFAULT NULL, `artist_old` varchar(255) DEFAULT NULL, `r
elease_date` datetime DEFAULT NULL, `genre` varchar(255) DEFAULT NULL, `feature`
int(11) DEFAULT NULL, `image_path` varchar(255) DEFAULT NULL, `created_at` date
time DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `artist_id` int(11) DEFAU
LT NULL) ENGINE=InnoDB
usually when you use the scaffold command it will create a migration in your
db/migrate/folder, containing all the database setup for your model, for example:If you have not successfully run the
rake db:migratecommand after you created the scaffold, you can just easily edit the migration file underdb/migrate/and add the field you missed in the beginning. After you edited the file, run therake db:migratecommand to apply the migration to your database.If you already stepped through
rake db:migrateafter creating your scaffold, you can create a new migration withscript/generate migration AddSubjectColumnToCommentsto add another field to your table. In my example above, I would get a new migration and fill in the following code:Good luck migrating!