diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..4a57cf0 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,2 @@ +class User < ActiveRecord::Base +end diff --git a/db/migrate/20151023163642_create_users.rb b/db/migrate/20151023163642_create_users.rb new file mode 100644 index 0000000..9500386 --- /dev/null +++ b/db/migrate/20151023163642_create_users.rb @@ -0,0 +1,12 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :email + t.string :password_digest, limit: 60 + + t.timestamps null: false + end + + add_index :users, :email, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 05e53c1..3becb29 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,54 +11,54 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151022110802) do +ActiveRecord::Schema.define(version: 20151023163642) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "categories", force: true do |t| - t.string "name" + create_table "categories", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" t.datetime "created_at" t.datetime "updated_at" t.integer "photo_id" - t.string "base_colour" + t.string "base_colour", limit: 255 t.integer "sort" - t.string "slug" + t.string "slug", limit: 255 end - create_table "categories_photos", id: false, force: true do |t| + create_table "categories_photos", id: false, force: :cascade do |t| t.integer "category_id" t.integer "photo_id" end add_index "categories_photos", ["category_id", "photo_id"], name: "index_categories_photos_on_category_id_and_photo_id", unique: true, using: :btree - create_table "pages", force: true do |t| - t.string "name" - t.string "title" + create_table "pages", force: :cascade do |t| + t.string "name", limit: 255 + t.string "title", limit: 255 t.text "content" t.datetime "created_at" t.datetime "updated_at" end - create_table "photos", force: true do |t| - t.string "flickr_url" + create_table "photos", force: :cascade do |t| + t.string "flickr_url", limit: 255 t.datetime "created_at" t.datetime "updated_at" - t.string "title" + t.string "title", limit: 255 t.text "description" t.integer "sort" - t.boolean "featured", default: false - t.boolean "enabled", default: true + t.boolean "featured", default: false + t.boolean "enabled", default: true t.datetime "taken_at" - t.integer "views", default: 0 - t.string "image_uid" - t.string "image_name" + t.integer "views", default: 0 + t.string "image_uid", limit: 255 + t.string "image_name", limit: 255 end - create_table "sessions", force: true do |t| - t.string "session_id", null: false + create_table "sessions", force: :cascade do |t| + t.string "session_id", limit: 255, null: false t.text "data" t.datetime "created_at" t.datetime "updated_at" @@ -67,4 +67,13 @@ ActiveRecord::Schema.define(version: 20151022110802) do add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree + create_table "users", force: :cascade do |t| + t.string "email" + t.string "password_digest", limit: 60 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + end diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 0000000..110df4c --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :user do + email "test@example.com" + password_digest "" + end + +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..47a31bb --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe User, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end