Error when try to create a Ticket State on rails


I’m trying to create a new ticket state on ruby’s console (listened here in community).

But when i’m run my code, i get this error.

Can anyone helps me? Pleeeeees :frowning:

Ubuntu 20.04.5 LTS Focal running in a VM on Hyper-V.

— My error —

irb(main):032:1* Ticket::State.create_or_update(
irb(main):033:1* name: ‘Developing’,
irb(main):034:1* state_type: Ticket::StateType.find_by(name: ‘in progress’),
irb(main):035:1* created_by_id: 1,
irb(main):036:1* updated_by_id: 1,
irb(main):037:0> )
/opt/zammad/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.4/lib/mysql2/client.rb:148:in _query': Mysql2::Error: Field 'state_type_id' doesn't have a default value (ActiveRecord::NotNullViolation) /opt/zammad/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.4/lib/mysql2/client.rb:148:in _query’: Field ‘state_type_id’ doesn’t have a default value (Mysql2::Error)

There is no such StateType “in progress”. This is the issue you actually have.

You can list all the currently available StateTypes with this command:
Ticket::StateType.pluck(:id, :name) (see: Working with ticket information — Zammad documentation)

Generally there should be

  • open
  • closed
  • pending reminder
  • pending action

depending on what you actually wanna use.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.