Browse Source

Created initial models

Dmitry Yu Okunev 5 years ago
parent
commit
0fe15a2c75

+ 3 - 0
.gitignore

@@ -15,3 +15,6 @@
 
 # Ignore Byebug command history file.
 .byebug_history
+
+# Ignore file with passwords.
+/config/database.yml

+ 0 - 24
README.md

@@ -1,24 +0,0 @@
-# README
-
-This README would normally document whatever steps are necessary to get the
-application up and running.
-
-Things you may want to cover:
-
-* Ruby version
-
-* System dependencies
-
-* Configuration
-
-* Database creation
-
-* Database initialization
-
-* How to run the test suite
-
-* Services (job queues, cache servers, search engines, etc.)
-
-* Deployment instructions
-
-* ...

+ 4 - 0
app/models/appointment.rb

@@ -0,0 +1,4 @@
+class Appointment < ApplicationRecord
+  belongs_to :person
+  belongs_to :unit
+end

+ 2 - 0
app/models/person.rb

@@ -0,0 +1,2 @@
+class Person < ApplicationRecord
+end

+ 2 - 0
app/models/unit.rb

@@ -0,0 +1,2 @@
+class Unit < ApplicationRecord
+end

config/database.yml → config/database.yml-sample


+ 13 - 0
db/migrate/20161026064026_create_units.rb

@@ -0,0 +1,13 @@
+class CreateUnits < ActiveRecord::Migration[5.0]
+  def change
+    create_table :units do |t|
+      t.string :code
+      t.string :name
+      t.string :fullname
+      t.string :shortname
+      t.integer :parent_id
+
+      t.timestamps
+    end
+  end
+end

+ 15 - 0
db/migrate/20161026064320_create_people.rb

@@ -0,0 +1,15 @@
+class CreatePeople < ActiveRecord::Migration[5.0]
+  def change
+    create_table :people do |t|
+      t.string :login
+      t.string :firstname
+      t.string :lastname
+      t.string :patronymic
+      t.string :displayname
+      t.string :displayname_latin
+      t.string :photo_url
+
+      t.timestamps
+    end
+  end
+end

+ 14 - 0
db/migrate/20161026064749_create_appointments.rb

@@ -0,0 +1,14 @@
+class CreateAppointments < ActiveRecord::Migration[5.0]
+  def change
+    create_table :appointments do |t|
+      t.references :person, foreign_key: true
+      t.references :unit, foreign_key: true
+      t.string :name
+      t.string :line
+      t.string :description
+      t.string :room
+
+      t.timestamps
+    end
+  end
+end

+ 52 - 0
db/schema.rb

@@ -0,0 +1,52 @@
+# 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: 20161026064749) do
+
+  create_table "appointments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
+    t.integer  "person_id"
+    t.integer  "unit_id"
+    t.string   "name"
+    t.string   "line"
+    t.string   "description"
+    t.string   "room"
+    t.datetime "created_at",  null: false
+    t.datetime "updated_at",  null: false
+    t.index ["person_id"], name: "index_appointments_on_person_id", using: :btree
+    t.index ["unit_id"], name: "index_appointments_on_unit_id", using: :btree
+  end
+
+  create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
+    t.string   "login"
+    t.string   "firstname"
+    t.string   "lastname"
+    t.string   "patronymic"
+    t.string   "displayname"
+    t.string   "displayname_latin"
+    t.string   "photo_url"
+    t.datetime "created_at",        null: false
+    t.datetime "updated_at",        null: false
+  end
+
+  create_table "units", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
+    t.string   "code"
+    t.string   "name"
+    t.string   "fullname"
+    t.string   "shortname"
+    t.integer  "parent_id"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+  end
+
+  add_foreign_key "appointments", "people"
+  add_foreign_key "appointments", "units"
+end

+ 17 - 0
test/fixtures/appointments.yml

@@ -0,0 +1,17 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+  user: one
+  unit: one
+  name: MyString
+  line: MyString
+  description: MyString
+  room: MyString
+
+two:
+  user: two
+  unit: two
+  name: MyString
+  line: MyString
+  description: MyString
+  room: MyString

+ 19 - 0
test/fixtures/people.yml

@@ -0,0 +1,19 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+  login: MyString
+  firstname: MyString
+  lastname: MyString
+  patronymic: MyString
+  displayname: MyString
+  displayname_latin: MyString
+  photo_url: MyString
+
+two:
+  login: MyString
+  firstname: MyString
+  lastname: MyString
+  patronymic: MyString
+  displayname: MyString
+  displayname_latin: MyString
+  photo_url: MyString

+ 15 - 0
test/fixtures/units.yml

@@ -0,0 +1,15 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+  code: MyString
+  name: MyString
+  fullname: MyString
+  shortname: MyString
+  parent_id: 0
+
+two:
+  code: MyString
+  name: MyString
+  fullname: MyString
+  shortname: MyString
+  parent_id: 1

+ 7 - 0
test/models/appointment_test.rb

@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AppointmentTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end

+ 7 - 0
test/models/person_test.rb

@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PersonTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end

+ 7 - 0
test/models/unit_test.rb

@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UnitTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end