Commit 53907c7b by Hoang Phuc Do

Create products, categories table

parent 833acdb3
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
\ No newline at end of file
class CreateCategories < ActiveRecord::Migration[5.1]
def change
create_table :categories do |t|
t.string :title
t.text :description
end
end
end
class CreateProducts < ActiveRecord::Migration[5.1]
def change
create_table :products do |t|
t.string :title
t.text :description
t.text :sku
t.decimal :price, precision: 8, scale: 2
t.references :category, foreign_key: true
t.timestamps
end
end
end
class AddImageColumnsToProducts < ActiveRecord::Migration[5.1]
def up
add_attachment :products, :image
end
def down
remove_attachment :products, :image
end
end
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170606064132) do
create_table "categories", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "title"
t.text "description"
end
create_table "products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "title"
t.text "description"
t.text "sku"
t.decimal "price", precision: 8, scale: 2
t.bigint "category_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.index ["category_id"], name: "index_products_on_category_id"
end
add_foreign_key "products", "categories"
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment