mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-28 21:07:16 +00:00
Adding enterprise limit to spree users
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
class AddEnterpriseLimitToSpreeUsers < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :spree_users, :enterprise_limit, :integer, default: 1, null: false
|
||||
|
||||
Spree::User.all.each do |u|
|
||||
e_count = u.owned_enterprises.length
|
||||
if u.admin? || e_count > 1
|
||||
e_limit = 100
|
||||
e_limit = 1000 if u.admin?
|
||||
u.update_column :enterprise_limit, e_limit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :spree_users, :enterprise_limit
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140828023619) do
|
||||
ActiveRecord::Schema.define(:version => 20140904003026) do
|
||||
|
||||
create_table "adjustment_metadata", :force => true do |t|
|
||||
t.integer "adjustment_id"
|
||||
@@ -971,6 +971,7 @@ ActiveRecord::Schema.define(:version => 20140828023619) do
|
||||
t.string "spree_api_key", :limit => 48
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.string "api_key", :limit => 40
|
||||
t.integer "enterprise_limit", :default => 1, :null => false
|
||||
end
|
||||
|
||||
add_index "spree_users", ["email"], :name => "email_idx_unique", :unique => true
|
||||
|
||||
Reference in New Issue
Block a user