-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.rb
41 lines (29 loc) · 830 Bytes
/
db.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# encoding: utf-8
require 'rubygems'
require 'bundler/setup'
require 'data_mapper'
DataMapper::setup(:default, "mysql://laoyuan:laoyuan@localhost/laoyuan")
class School
include DataMapper::Resource
property :id, Serial
property :username, String, :required => true, :unique => true
property :password, BCryptHash, :required => true
property :school_name, String, :required => true
has n, :teachers
end
class Teacher
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
property :subject, String, :required => true
property :gender, String
property :age, String
belongs_to :school
end
class Question
include DataMapper::Resource
property :id, Serial
property :description, String, :required => true
end
DataMapper.finalize
DataMapper.auto_upgrade!