I was getting this error when running 'rake db:migrate' with sqlite:
SQLite3::SQLException: Cannot add a NOT NULL column with default value NULL: ALTER TABLE
"deployables" ADD "uuid" varchar(255) NOT NULL
To avoid the warning, we can add the column as nullable and then change
it to non-null later.
Presumably this would fail if we ran the migration on a DB containing
any data in the deployables table, but this is unlikely. To avoid it,
we could do e.g.
Deployable.reset_column_information
Deployable.all.each do |deployable|
deployable.uuid = "" if deployable.uuid.nil?
deployable.xml = "" if deployable.xml.nil?
end
but that seems like overkill given the situation, especially since the
default values don't make any sense.
---
.../migrate/20110207100800_update_deployables.rb | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/db/migrate/20110207100800_update_deployables.rb
b/src/db/migrate/20110207100800_update_deployables.rb
index 4414560..ff87bed 100644
--- a/src/db/migrate/20110207100800_update_deployables.rb
+++ b/src/db/migrate/20110207100800_update_deployables.rb
@@ -2,13 +2,16 @@ class UpdateDeployables < ActiveRecord::Migration
def self.up
change_table :deployables do |t|
t.integer :lock_version, :default => 0
- t.string :uuid, :null => false
- t.binary :xml, :null => false
+ t.string :uuid
+ t.binary :xml
t.string :uri
t.text :summary
t.boolean :uploaded, :default => false
end
+ change_column :deployables, :uuid, :string, :null => false
+ change_column :deployables, :xml, :string, :null => false
+
create_table :assemblies_deployables, :id => false do |t|
t.integer :assembly_id, :null => false
t.integer :deployable_id, :null => false
--
1.7.4.4
Show replies by date