Skip to content

Commit

Permalink
Remove default value for state from sources table, to fix problem wit…
Browse files Browse the repository at this point in the history
…h statemachine

See this page for more information:
pluginaweek/state_machine#279
  • Loading branch information
martyn-w committed Nov 5, 2013
1 parent c230974 commit c4e7a0c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 11 additions & 0 deletions db/migrate/20131105105631_remove_state_default_from_sources.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class RemoveStateDefaultFromSources < ActiveRecord::Migration
def up
# Remove default from state column as this causes an error to be thrown: "Both Source and its :state machine have defined a different default for "state". Use only one or the other for defining defaults to avoid unexpected behaviors."
# See this page for more information: https://github.com/pluginaweek/state_machine/issues/279
change_column_default(:sources, :state, nil)
end

def down
change_column_default(:sources, :state, 0)
end
end
14 changes: 12 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20131023173939) do
ActiveRecord::Schema.define(:version => 20131105105631) do

create_table "alerts", :force => true do |t|
t.integer "source_id"
Expand Down Expand Up @@ -155,6 +155,8 @@
end

add_index "retrieval_statuses", ["article_id", "source_id"], :name => "index_retrieval_statuses_on_article_id_and_source_id", :unique => true
add_index "retrieval_statuses", ["source_id", "article_id", "event_count"], :name => "index_retrieval_statuses_source_id_article_id_event_count_desc"
add_index "retrieval_statuses", ["source_id", "event_count"], :name => "index_retrieval_statuses_source_id_event_count_desc"

create_table "reviews", :force => true do |t|
t.string "name"
Expand Down Expand Up @@ -182,7 +184,7 @@
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "description"
t.integer "state", :default => 0
t.integer "state"
t.boolean "queueable", :default => true
t.string "state_event"
end
Expand Down Expand Up @@ -217,6 +219,14 @@
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
add_index "users", ["username"], :name => "index_users_username", :unique => true

create_table "vw_retrieval_statuses_published_on", :id => false, :force => true do |t|
t.integer "id", :default => 0, :null => false
t.integer "article_id", :null => false
t.integer "source_id", :null => false
t.integer "event_count", :default => 0
t.date "published_on"
end

create_table "workers", :force => true do |t|
t.integer "identifier", :null => false
t.string "queue", :null => false
Expand Down

0 comments on commit c4e7a0c

Please sign in to comment.