diff --git a/Gemfile b/Gemfile index 703ed40..4898a53 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,7 @@ gem 'font-awesome-rails' gem 'jbuilder', '~> 2.5' gem 'jquery-rails' gem 'pg', '~> 0.18' +gem 'public_activity' gem 'puma', '~> 3.0' gem 'rails', '~> 5.0.1' gem 'rainbow', '>= 2.1.0', '< 2.2.0' # workaround for bundler errors diff --git a/Gemfile.lock b/Gemfile.lock index 7a22529..7691e65 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,6 +162,11 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + public_activity (1.5.0) + actionpack (>= 3.0.0) + activerecord (>= 3.0) + i18n (>= 0.5.0) + railties (>= 3.0.0) public_suffix (2.0.5) puma (3.6.2) rack (2.0.1) @@ -327,6 +332,7 @@ DEPENDENCIES launchy listen (~> 3.0.5) pg (~> 0.18) + public_activity puma (~> 3.0) rails (~> 5.0.1) rails-assets-tether (>= 1.3.3)! @@ -349,4 +355,4 @@ DEPENDENCIES web-console (>= 3.3.0) BUNDLED WITH - 1.14.3 + 1.14.4 diff --git a/db/migrate/20170221091555_create_activities.rb b/db/migrate/20170221091555_create_activities.rb new file mode 100644 index 0000000..51d0b12 --- /dev/null +++ b/db/migrate/20170221091555_create_activities.rb @@ -0,0 +1,24 @@ +# Migration responsible for creating a table with activities +class CreateActivities < ActiveRecord::Migration + # Create table + def self.up + create_table :activities do |t| + t.belongs_to :trackable, polymorphic: true + t.belongs_to :owner, polymorphic: true + t.string :key + t.text :parameters + t.belongs_to :recipient, polymorphic: true + + t.timestamps + end + + add_index :activities, [:trackable_id, :trackable_type] + add_index :activities, [:owner_id, :owner_type] + add_index :activities, [:recipient_id, :recipient_type] + end + + # Drop table + def self.down + drop_table :activities + end +end diff --git a/db/schema.rb b/db/schema.rb index 5160a19..180c569 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20_170_215_121_139) do +ActiveRecord::Schema.define(version: 20_170_221_091_555) do # These are extensions that must be enabled in order to support this database enable_extension 'plpgsql' @@ -21,13 +21,20 @@ t.integer 'creator_id' end - create_table 'invites', force: :cascade do |t| - t.integer 'room_id' - t.integer 'sender_id' + create_table 'activities', force: :cascade do |t| + t.string 'trackable_type' + t.integer 'trackable_id' + t.string 'owner_type' + t.integer 'owner_id' + t.string 'key' + t.text 'parameters' + t.string 'recipient_type' t.integer 'recipient_id' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['room_id'], name: 'index_invites_on_room_id', using: :btree + t.datetime 'created_at' + t.datetime 'updated_at' + t.index %w(owner_id owner_type), name: 'index_activities_on_owner_id_and_owner_type', using: :btree + t.index %w(recipient_id recipient_type), name: 'index_activities_on_recipient_id_and_recipient_type', using: :btree + t.index %w(trackable_id trackable_type), name: 'index_activities_on_trackable_id_and_trackable_type', using: :btree end create_table 'room_actions', id: false, force: :cascade do |t| @@ -81,7 +88,6 @@ t.index ['room_id'], name: 'index_users_on_room_id', using: :btree end - add_foreign_key 'invites', 'rooms' add_foreign_key 'room_actions', 'actions' add_foreign_key 'room_actions', 'rooms' add_foreign_key 'room_requests', 'rooms'