4

Sorry for the annoying question, but I didn't find the way to create a table with a CHAR column. I want CHAR, not VARCHAR!

In the documentation, they don't write anything about CHAR type columns: http://laravel.com/docs/database/schema

What if I want a CHAR(6) type column where only 6 char long strings are allowed, must I create a varchar column and forbid in the model to be shorter or longer than 6 char?

1 Answer 1

5

As you say the laravel documentation doesn't support a CHAR datatype. That's all there is to it.

But that is probably beside the point. CHAR(6) does not enforce a rule that all values must be six characters long. What it does is right-pad any input to six characters. So we can enter 'A' and the CHAR column will store 'A '. Is that really what you want?

Sign up to request clarification or add additional context in comments.

1 Comment

Then my conjecture was right :D. I create those min max rules anyway, but i wasnt sure about using varchar for this, but its ok. Thank you for the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.