diff --git a/app/models/page.rb b/app/models/page.rb new file mode 100644 index 0000000..ee51575 --- /dev/null +++ b/app/models/page.rb @@ -0,0 +1,2 @@ +class Page < ApplicationRecord +end diff --git a/app/models/section.rb b/app/models/section.rb new file mode 100644 index 0000000..ec21dc1 --- /dev/null +++ b/app/models/section.rb @@ -0,0 +1,2 @@ +class Section < ApplicationRecord +end diff --git a/app/models/subject.rb b/app/models/subject.rb new file mode 100644 index 0000000..8857c6e --- /dev/null +++ b/app/models/subject.rb @@ -0,0 +1,2 @@ +class Subject < ApplicationRecord +end diff --git a/db/migrate/20160920032941_create_subjects.rb b/db/migrate/20160920032941_create_subjects.rb new file mode 100644 index 0000000..3002a33 --- /dev/null +++ b/db/migrate/20160920032941_create_subjects.rb @@ -0,0 +1,13 @@ +class CreateSubjects < ActiveRecord::Migration[5.0] + def up + create_table :subjects do |t| + t.string "name" + t.integer "position" + t.boolean "visible", :default => false + t.timestamps + end + end + def down + drop_table "subjects" + end +end diff --git a/db/migrate/20160920033109_create_pages.rb b/db/migrate/20160920033109_create_pages.rb new file mode 100644 index 0000000..ef7679b --- /dev/null +++ b/db/migrate/20160920033109_create_pages.rb @@ -0,0 +1,20 @@ +class CreatePages < ActiveRecord::Migration[5.0] + def up + create_table :pages do |t| + t.integer "subject_id" + # same as t.references :subject + + t.string "name" + t.string "permalink" + t.integer "position" + t.boolean "visible", :default => false + + t.timestamps + end + add_index("pages", "permalink") + add_index("pages", "subject_id") + end + def down + drop_table("pages") + end +end diff --git a/db/migrate/20160920033121_create_sections.rb b/db/migrate/20160920033121_create_sections.rb new file mode 100644 index 0000000..edce412 --- /dev/null +++ b/db/migrate/20160920033121_create_sections.rb @@ -0,0 +1,15 @@ +class CreateSections < ActiveRecord::Migration[5.0] + # Example of change action, will only work if all commands on up are reversible. + def change + create_table :sections do |t| + t.references :page + + t.string "name" + t.integer "position" + t.boolean "visible", :default => false + t.string "content_type" + t.text "content" + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 52ab025..1bcb398 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,6 +10,49 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 0) do +ActiveRecord::Schema.define(version: 20160920033121) do + + create_table "admin_users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + t.string "first_name", limit: 25 + t.string "last_name", limit: 50 + t.string "email", limit: 100, default: "", null: false + t.string "username", limit: 25 + t.string "hashed_password", limit: 40 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["username"], name: "index_admin_users_on_username", using: :btree + end + + create_table "pages", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + t.integer "subject_id" + t.string "name" + t.string "permalink" + t.integer "position" + t.boolean "visible", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["permalink"], name: "index_pages_on_permalink", using: :btree + t.index ["subject_id"], name: "index_pages_on_subject_id", using: :btree + end + + create_table "sections", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + t.integer "page_id" + t.string "name" + t.integer "position" + t.boolean "visible", default: false + t.string "content_type" + t.text "content", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["page_id"], name: "index_sections_on_page_id", using: :btree + end + + create_table "subjects", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + t.string "name" + t.integer "position" + t.boolean "visible", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end end diff --git a/test/fixtures/pages.yml b/test/fixtures/pages.yml new file mode 100644 index 0000000..80aed36 --- /dev/null +++ b/test/fixtures/pages.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/sections.yml b/test/fixtures/sections.yml new file mode 100644 index 0000000..80aed36 --- /dev/null +++ b/test/fixtures/sections.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/subjects.yml b/test/fixtures/subjects.yml new file mode 100644 index 0000000..80aed36 --- /dev/null +++ b/test/fixtures/subjects.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/page_test.rb b/test/models/page_test.rb new file mode 100644 index 0000000..e7400b9 --- /dev/null +++ b/test/models/page_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PageTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/section_test.rb b/test/models/section_test.rb new file mode 100644 index 0000000..b8b5039 --- /dev/null +++ b/test/models/section_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SectionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/subject_test.rb b/test/models/subject_test.rb new file mode 100644 index 0000000..d54e76f --- /dev/null +++ b/test/models/subject_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SubjectTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end