Iker Narvaez

added seeds & papaertrail

1 +PaperTrail.config.track_associations = false
1 +# This migration creates the `versions` table, the only schema PT requires.
2 +# All other migrations PT provides are optional.
3 +class CreateVersions < ActiveRecord::Migration[5.0]
4 +
5 + # The largest text column available in all supported RDBMS is
6 + # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
7 + # so that MySQL will use `longtext` instead of `text`. Otherwise,
8 + # when serializing very large objects, `text` might not be big enough.
9 + TEXT_BYTES = 1_073_741_823
10 +
11 + def change
12 + create_table :versions do |t|
13 + t.string :item_type, {:null=>false}
14 + t.integer :item_id, null: false
15 + t.string :event, null: false
16 + t.string :whodunnit
17 + t.text :object, limit: TEXT_BYTES
18 +
19 + # Known issue in MySQL: fractional second precision
20 + # -------------------------------------------------
21 + #
22 + # MySQL timestamp columns do not support fractional seconds unless
23 + # defined with "fractional seconds precision". MySQL users should manually
24 + # add fractional seconds precision to this migration, specifically, to
25 + # the `created_at` column.
26 + # (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)
27 + #
28 + # MySQL users should also upgrade to rails 4.2, which is the first
29 + # version of ActiveRecord with support for fractional seconds in MySQL.
30 + # (https://github.com/rails/rails/pull/14359)
31 + #
32 + t.datetime :created_at
33 + end
34 + add_index :versions, %i(item_type item_id)
35 + end
36 +end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
10 # 10 #
11 # It's strongly recommended that you check this file into your version control system. 11 # It's strongly recommended that you check this file into your version control system.
12 12
13 -ActiveRecord::Schema.define(version: 20180608220338) do 13 +ActiveRecord::Schema.define(version: 20180608221109) do
14 14
15 # These are extensions that must be enabled in order to support this database 15 # These are extensions that must be enabled in order to support this database
16 enable_extension "plpgsql" 16 enable_extension "plpgsql"
...@@ -65,4 +65,14 @@ ActiveRecord::Schema.define(version: 20180608220338) do ...@@ -65,4 +65,14 @@ ActiveRecord::Schema.define(version: 20180608220338) do
65 t.index ["user_id"], name: "index_users_roles_on_user_id", using: :btree 65 t.index ["user_id"], name: "index_users_roles_on_user_id", using: :btree
66 end 66 end
67 67
68 + create_table "versions", force: :cascade do |t|
69 + t.string "item_type", null: false
70 + t.integer "item_id", null: false
71 + t.string "event", null: false
72 + t.string "whodunnit"
73 + t.text "object"
74 + t.datetime "created_at"
75 + t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
76 + end
77 +
68 end 78 end
......
...@@ -5,3 +5,7 @@ ...@@ -5,3 +5,7 @@
5 # 5 #
6 # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 6 # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7 # Character.create(name: 'Luke', movie: movies.first) 7 # Character.create(name: 'Luke', movie: movies.first)
8 +admin = Role.create(name: 'SuperAdmin', erasable: false)
9 +user = Role.create(name: 'Player', erasable: false)
10 +User.new(name: 'Iker', mail: 'i.narvaez@ukko.mx', password: '12345', password_confirmation: '12345', roles: [admin, player])
11 +User.new(name: 'Iker', mail: 'p.sanches@ukko.mx', password: '12345', password_confirmation: '12345', roles: [admin, player])
......