0

I'm trying to set a default value for a decimal column. But I still received a "Not null violation error".

What I have tried:

  1. default('0')
  2. default(0)
  3. default('0.00') (solution from another stack overflow question)
  4. default('00000000000000000.00')
  5. default(0.00)

None of what I've tried works. Does anyone know how to fix this?

Migration file

Not null violation error

3
  • have you tried default(0.00), pass other non-zero double like 0.12 in order to validate format or disabling SQL strict mode? Commented Nov 2, 2021 at 6:19
  • @moonvader still not null violation Commented Nov 2, 2021 at 6:35
  • the migration is probably working, but you are passing the null value in the query when you insert new records Commented Nov 2, 2021 at 7:02

2 Answers 2

0

try this

$table->decimal('exit_fee', 19, 2)->default('00000000000000000.00');

and run migrate will see

https://i.sstatic.net/k8NQF.png

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

1 Comment

still not null violation
0

I saw this in a different question wich kind of resembles your question.

$table->decimal('exit_fee', 19, 2)->default('00000000000000000');

Comments

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.