Laravel 5 registration form

hello

I would like to add another inputbox in my laravel registration form which is :"username"

here is my current schema


 
public function up()
	{
		Schema::create('users', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name');
			$table->string('email')->unique();
			$table->string('password', 60);
			$table->rememberToken();
			$table->timestamps();
		});
	}

Open in new window


I added this line:
                   
$table->string('username', 20)->unique();

Open in new window


I tried to do a migration refresh, and it seems that i flashed all my previous data in the DB

my question is: how to add this line and update my DB via migration without affecting my current DB's Data.

Also, the username field has been added in the DB, I added that field into HTML but when I try to register, the DB does NOT take that input data, and it shows it blank.

When I tried to re-register with the same username I got an error:

Whoops, looks like something went wrong.

2/2
QueryException in Connection.php line 620:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'users_username_unique' (SQL: insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (test, test@test.com, y$V2U2ziviKuHMoI1rva93QesxBAFyrA29AAEpUNtmAQh/SQa.xO45e, 2015-05-07 21:11:30, 2015-05-07 21:11:30))
in Connection.php line 620
at Connection->runQueryCallback('insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?)', array('test', 'test@test.com', '$2y$10$V2U2ziviKuHMoI1rva93QesxBAFyrA29AAEpUNtmAQh/SQa.xO45e', '2015-05-07 21:11:30', '2015-05-07 21:11:30'), object(Closure)) in Connection.php line 576
at Connection->run('insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?)', array('test', 'test@test.com', '$2y$10$V2U2ziviKuHMoI1rva93QesxBAFyrA29AAEpUNtmAQh/SQa.xO45e', '2015-05-07 21:11:30', '2015-05-07 21:11:30'), object(Closure)) in Connection.php line 359
at Connection->statement('insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?)', array('test', 'test@test.com', '$2y$10$V2U2ziviKuHMoI1rva93QesxBAFyrA29AAEpUNtmAQh/SQa.xO45e', '2015-05-07 21:11:30', '2015-05-07 21:11:30')) in Connection.php line 316

Open in new window


....
adra750Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

adra750Author Commented:
I fixed it,

I only need to know, how to add a column without affecting my existing DB
0
Ray PaseurCommented:
Just add a migration.  Note that I said "add a migration" not "go back and change an existing migration to add a column."  You can (and should) have multiple migration steps, allowing you to go back to earlier migration points, or to refresh and re-seed the entire database.

Each migration builds on the work of all the migrations before it, and if you change a migration you risk changing some of the dependencies in the migration cascade.  So instead of changing a migration after it is added to the system, just add another migration to achieve the purpose.

FWIW, I find the migration system to be a bit clunky - almost like it trips over GitHub version control at some points.  So you want to be very careful about following the rules with migrations, otherwise it can be difficult to sort it out once an error has worked its way in!

Best of luck with your project, ~Ray
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Frameworks

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.