Pflichtenhefte: type_id darf nicht NULL sein
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 2 Apr 2014 11:50:13 +0000 (13:50 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 2 Apr 2014 12:13:15 +0000 (14:13 +0200)
SL/DB/MetaSetup/RequirementSpec.pm
sql/Pg-upgrade2/requirement_spec_type_for_template_fix.sql [new file with mode: 0644]

index 448816a..667f39a 100644 (file)
@@ -22,7 +22,7 @@ __PACKAGE__->meta->columns(
   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' },
 );
 
diff --git a/sql/Pg-upgrade2/requirement_spec_type_for_template_fix.sql b/sql/Pg-upgrade2/requirement_spec_type_for_template_fix.sql
new file mode 100644 (file)
index 0000000..a786439
--- /dev/null
@@ -0,0 +1,11 @@
+-- @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;