mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-26 09:04:07 +01:00
this patch includes a fix to the sqlite adapter to support changing NOT NULL constraints on existing sqlite databases. This fix is part of rails 2.0, but not part of rails 1.2.6 which is baseline for tracks 1.5.
Also this patch includes a migration to remove the NOT NULL constaint from the position field of contexts and projects. Should solve #640 git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@722 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
510048178a
commit
1de273c96e
2 changed files with 23 additions and 0 deletions
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue