diff --git a/tracks/db/migrate/038_projects_contexts_remove_not_null_from_position.rb b/tracks/db/migrate/038_projects_contexts_remove_not_null_from_position.rb new file mode 100644 index 00000000..fe9e198f --- /dev/null +++ b/tracks/db/migrate/038_projects_contexts_remove_not_null_from_position.rb @@ -0,0 +1,22 @@ +class ProjectsContextsRemoveNotNullFromPosition < ActiveRecord::Migration + def self.up + change_column :projects, :position, :string, :null => true + change_column :contexts, :position, :string, :null => true + end + + def self.down + @projects = Project.find(:all) + @projects.each do |project| + project.position = 0 if !project.position? + project.save + end + change_column :projects, :position, :string, :null => false + + @contexts = Context.find(:all) + @contexts.each do |context| + context.position = 0 if !context.position? + context.save + end + change_column :contexts, :position, :string, :null => false + end +end diff --git a/tracks/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/tracks/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 0a9c57e1..fbfd79f3 100644 --- a/tracks/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/tracks/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -259,6 +259,7 @@ module ActiveRecord self.type = type self.limit = options[:limit] if options.include?(:limit) self.default = options[:default] if include_default + self.null = options[:null] if options.include?(:null) end end end