status_id               => { type => 'integer' },
   time_estimation         => { type => 'numeric', default => '0', not_null => 1, precision => 12, scale => 2 },
   title                   => { type => 'text', not_null => 1 },
-  type_id                 => { type => 'integer' },
+  type_id                 => { type => 'integer', not_null => 1 },
   working_copy_id         => { type => 'integer' },
 );
 
 
--- /dev/null
+-- @tag: requirement_spec_type_for_template_fix
+-- @description: requirement_spec_type_for_template_fix
+-- @depends: requirement_spec_types_number_formats
+UPDATE requirement_specs
+SET type_id = (
+  SELECT MIN(id)
+  FROM requirement_spec_types
+)
+WHERE type_id IS NULL;
+
+ALTER TABLE requirement_specs ALTER COLUMN type_id SET NOT NULL;