db/schema.rb doesn't match

38 views
Skip to first unread message

ffa

unread,
May 9, 2012, 9:25:06 PM5/9/12
to fat-free-...@googlegroups.com
hey,

 The db/schema.rb doesn't match db/migrate. And, because of that, for those who are upgrading, there are some null field differences between the expected database schema and the actual db schema. Please create a db/migrate to fix the differences. Or, is the current schema.rb wrong?

This is when the change was made to the schema.rb:
https://github.com/fatfreecrm/fat_free_crm/commit/d6be19638b245404e860fa4238a4723f9c865d74#db/schema.rb

diff --git a/db/schema.rb b/db/schema.rb
index a671f17..a1b930b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -17,16 +17,16 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.integer  "account_id"
     t.integer  "contact_id"
     t.datetime "deleted_at"
-    t.datetime "created_at", :null => false
-    t.datetime "updated_at", :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   create_table "account_opportunities", :force => true do |t|
     t.integer  "account_id"
     t.integer  "opportunity_id"
     t.datetime "deleted_at"
-    t.datetime "created_at",     :null => false
-    t.datetime "updated_at",     :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   create_table "accounts", :force => true do |t|
@@ -39,8 +39,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.string   "phone",            :limit => 32
     t.string   "fax",              :limit => 32
     t.datetime "deleted_at"
-    t.datetime "created_at",                                           :null => false
-    t.datetime "updated_at",                                           :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "email",            :limit => 64
     t.string   "background_info"
     t.integer  "rating",                         :default => 0,        :null => false
@@ -58,8 +58,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.string   "action",       :limit => 32, :default => "created"
     t.string   "info",                       :default => ""
     t.boolean  "private",                    :default => false
-    t.datetime "created_at",                                        :null => false
-    t.datetime "updated_at",                                        :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   add_index "activities", ["created_at"], :name => "index_activities_on_created_at"
@@ -76,8 +76,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.string   "address_type",     :limit => 16
     t.integer  "addressable_id"
     t.string   "addressable_type"
-    t.datetime "created_at",                     :null => false
-    t.datetime "updated_at",                     :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.datetime "deleted_at"
   end

@@ -90,8 +90,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.integer  "image_file_size"
     t.string   "image_file_name"
     t.string   "image_content_type"
-    t.datetime "created_at",         :null => false
-    t.datetime "updated_at",         :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   create_table "campaigns", :force => true do |t|
@@ -111,8 +111,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.date     "ends_on"
     t.text     "objectives"
     t.datetime "deleted_at"
-    t.datetime "created_at",                                                                             :null => false
-    t.datetime "updated_at",                                                                             :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "background_info"
     t.text     "subscribed_users"
   end
@@ -127,8 +127,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.boolean  "private"
     t.string   "title",                          :default => ""
     t.text     "comment"
-    t.datetime "created_at",                                             :null => false
-    t.datetime "updated_at",                                             :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "state",            :limit => 16, :default => "Expanded", :null => false
   end

@@ -137,8 +137,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.integer  "opportunity_id"
     t.string   "role",           :limit => 32
     t.datetime "deleted_at"
-    t.datetime "created_at",                   :null => false
-    t.datetime "updated_at",                   :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   create_table "contacts", :force => true do |t|
@@ -164,8 +164,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.date     "born_on"
     t.boolean  "do_not_call",                     :default => false,    :null => false
     t.datetime "deleted_at"
-    t.datetime "created_at",                                            :null => false
-    t.datetime "updated_at",                                            :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "background_info"
     t.string   "skype",            :limit => 128
     t.text     "subscribed_users"
@@ -189,8 +189,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.datetime "sent_at"
     t.datetime "received_at"
     t.datetime "deleted_at"
-    t.datetime "created_at",                                            :null => false
-    t.datetime "updated_at",                                            :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "state",           :limit => 16, :default => "Expanded", :null => false
   end

@@ -201,8 +201,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.string   "label",      :limit => 128
     t.integer  "position"
     t.string   "hint"
-    t.datetime "created_at",                :null => false
-    t.datetime "updated_at",                :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.integer  "tag_id"
     t.string   "klass_name", :limit => 32
   end
@@ -220,8 +220,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.boolean  "disabled"
     t.boolean  "required"
     t.integer  "maxlength"
-    t.datetime "created_at",                    :null => false
-    t.datetime "updated_at",                    :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   add_index "fields", ["field_group_id"], :name => "index_fields_on_field_group_id"
@@ -250,8 +250,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.integer  "rating",                          :default => 0,        :null => false
     t.boolean  "do_not_call",                     :default => false,    :null => false
     t.datetime "deleted_at"
-    t.datetime "created_at",                                            :null => false
-    t.datetime "updated_at",                                            :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "background_info"
     t.string   "skype",            :limit => 128
     t.text     "subscribed_users"
@@ -263,8 +263,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
   create_table "lists", :force => true do |t|
     t.string   "name"
     t.text     "url"
-    t.datetime "created_at", :null => false
-    t.datetime "updated_at", :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end
   create_table "opportunities", :force => true do |t|
@@ -280,8 +280,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.decimal  "discount",                       :precision => 12, :scale => 2
     t.date     "closes_on"
     t.datetime "deleted_at"
-    t.datetime "created_at",                                                                          :null => false
-    t.datetime "updated_at",                                                                          :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "background_info"
     t.text     "subscribed_users"
   end
@@ -293,8 +293,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.integer  "user_id"
     t.integer  "asset_id"
     t.string   "asset_type"
-    t.datetime "created_at", :null => false
-    t.datetime "updated_at", :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   add_index "permissions", ["asset_id", "asset_type"], :name => "index_permissions_on_asset_id_and_asset_type"
@@ -304,8 +304,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.integer  "user_id"
     t.string   "name",       :limit => 32, :default => "", :null => false
     t.text     "value"
-    t.datetime "created_at",                               :null => false
-    t.datetime "updated_at",                               :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   add_index "preferences", ["user_id", "name"], :name => "index_preferences_on_user_id_and_name"
@@ -313,8 +313,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
   create_table "sessions", :force => true do |t|
     t.string   "session_id", :null => false
     t.text     "data"
-    t.datetime "created_at", :null => false
-    t.datetime "updated_at", :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
@@ -323,8 +323,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
   create_table "settings", :force => true do |t|
     t.string   "name",       :limit => 32, :default => "", :null => false
     t.text     "value"
-    t.datetime "created_at",                               :null => false
-    t.datetime "updated_at",                               :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
   end

   add_index "settings", ["name"], :name => "index_settings_on_name"
@@ -359,8 +359,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.datetime "due_at"
     t.datetime "completed_at"
     t.datetime "deleted_at"
-    t.datetime "created_at",                                     :null => false
-    t.datetime "updated_at",                                     :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.string   "background_info"
     t.text     "subscribed_users"
   end
@@ -393,8 +393,8 @@ ActiveRecord::Schema.define(:version => 20120413034923) do
     t.string   "current_login_ip"
     t.integer  "login_count",                       :default => 0,     :null => false
     t.datetime "deleted_at"
-    t.datetime "created_at",                                           :null => false
-    t.datetime "updated_at",                                           :null => false
+    t.datetime "created_at"
+    t.datetime "updated_at"
     t.boolean  "admin",                             :default => false, :null => false
     t.datetime "suspended_at"
     t.string   "single_access_token"

ako...@mindboxstudios.com

unread,
May 9, 2012, 9:31:31 PM5/9/12
to fat-free-...@googlegroups.com
Note: the diff I provided is the difference between my schema.rb and origin/master's schema.rb. My local branch is the current latest tagged version, v0.11.3.

Nathan Broadbent

unread,
May 9, 2012, 9:59:37 PM5/9/12
to fat-free-...@googlegroups.com
Hi,

I might be wrong on this, but it could be because we are using Postgres, and you might be using MySQL?
When I run `rake db:drop db:create db:migrate`, it executes 'db:schema:dump', and there is no change to the schema in origin/master.

Are you using Postgres, or a different db?

Thanks,
Nathan

--
You received this message because you are subscribed to the Google Groups "Fat Free CRM Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/fat-free-crm-users/-/kT8Hv_LrERsJ.

To post to this group, send email to fat-free-...@googlegroups.com.
To unsubscribe from this group, send email to fat-free-crm-us...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fat-free-crm-users?hl=en.

Steve Kenworthy

unread,
May 9, 2012, 10:04:58 PM5/9/12
to fat-free-...@googlegroups.com
I had a similar thought but just tried "rake db:create db:migrate db:schema:dump" on postgres and mysql... they both output the same schema.rb file which is different to what's checked as ffa noted.

+1 for ffa's migration suggestion.

Steve

Nathan Broadbent

unread,
May 9, 2012, 10:47:43 PM5/9/12
to fat-free-...@googlegroups.com
Ah, I see! Rails 3.2 changed the behavior of "t.timestamps" in migrations, which now adds those null conditions. So it happens when migrating your existing database, from before the Rails 3.2 update.
Alright, I will add a migration to update those columns.

Cheers
Nathan

Nathan Broadbent

unread,
May 9, 2012, 11:17:08 PM5/9/12
to fat-free-...@googlegroups.com
Hi there,

I've added the migration for ':null => false' constraints, please let us know if you have any more problems.

Cheers
Nathan

Steve Kenworthy

unread,
May 10, 2012, 12:31:51 AM5/10/12
to fat-free-...@googlegroups.com
Works a treat. Thanks!
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages