Description:
created join tables for contests and users and problems
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r268:5fffb74cc182 - - 6 files changed: 42 inserted, 1 deleted
@@ -0,0 +1,12 | |||||
|
|
1 | + class CreateContestsUsersJoinTable < ActiveRecord::Migration | ||
|
|
2 | + def self.up | ||
|
|
3 | + create_table :contests_users, :id => false do |t| | ||
|
|
4 | + t.integer :contest_id | ||
|
|
5 | + t.integer :user_id | ||
|
|
6 | + end | ||
|
|
7 | + end | ||
|
|
8 | + | ||
|
|
9 | + def self.down | ||
|
|
10 | + drop_table :contests_users | ||
|
|
11 | + end | ||
|
|
12 | + end |
@@ -0,0 +1,12 | |||||
|
|
1 | + class CreateContestsProblemsJoinTable < ActiveRecord::Migration | ||
|
|
2 | + def self.up | ||
|
|
3 | + create_table :contests_problems, :id => false do |t| | ||
|
|
4 | + t.integer :contest_id | ||
|
|
5 | + t.integer :problem_id | ||
|
|
6 | + end | ||
|
|
7 | + end | ||
|
|
8 | + | ||
|
|
9 | + def self.down | ||
|
|
10 | + drop_table :contests_problems | ||
|
|
11 | + end | ||
|
|
12 | + end |
@@ -1,2 +1,6 | |||||
|
1 | class Contest < ActiveRecord::Base |
|
1 | class Contest < ActiveRecord::Base |
|
|
2 | + | ||
|
|
3 | + has_and_belongs_to_many :users | ||
|
|
4 | + has_and_belongs_to_many :problems | ||
|
|
5 | + | ||
|
2 | end |
|
6 | end |
@@ -1,6 +1,7 | |||||
|
1 | class Problem < ActiveRecord::Base |
|
1 | class Problem < ActiveRecord::Base |
|
2 |
|
2 | ||
|
3 | belongs_to :description |
|
3 | belongs_to :description |
|
|
4 | + has_and_belongs_to_many :contests | ||
|
4 | has_many :test_pairs, :dependent => :delete_all |
|
5 | has_many :test_pairs, :dependent => :delete_all |
|
5 |
|
6 | ||
|
6 | validates_presence_of :name |
|
7 | validates_presence_of :name |
@@ -21,6 +21,8 | |||||
|
21 | belongs_to :site |
|
21 | belongs_to :site |
|
22 | belongs_to :country |
|
22 | belongs_to :country |
|
23 |
|
23 | ||
|
|
24 | + has_and_belongs_to_many :contests | ||
|
|
25 | + | ||
|
24 | named_scope :activated_users, :conditions => {:activated => true} |
|
26 | named_scope :activated_users, :conditions => {:activated => true} |
|
25 |
|
27 | ||
|
26 | validates_presence_of :login |
|
28 | validates_presence_of :login |
@@ -9,7 +9,7 | |||||
|
9 | # |
|
9 | # |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
11 |
|
11 | ||
|
12 |
- ActiveRecord::Schema.define(:version => 201002161 |
|
12 | + ActiveRecord::Schema.define(:version => 20100216162940) do |
|
13 |
|
13 | ||
|
14 | create_table "announcements", :force => true do |t| |
|
14 | create_table "announcements", :force => true do |t| |
|
15 | t.string "author" |
|
15 | t.string "author" |
@@ -46,6 +46,16 | |||||
|
46 | t.datetime "updated_at" |
|
46 | t.datetime "updated_at" |
|
47 | end |
|
47 | end |
|
48 |
|
48 | ||
|
|
49 | + create_table "contests_problems", :id => false, :force => true do |t| | ||
|
|
50 | + t.integer "contest_id" | ||
|
|
51 | + t.integer "problem_id" | ||
|
|
52 | + end | ||
|
|
53 | + | ||
|
|
54 | + create_table "contests_users", :id => false, :force => true do |t| | ||
|
|
55 | + t.integer "contest_id" | ||
|
|
56 | + t.integer "user_id" | ||
|
|
57 | + end | ||
|
|
58 | + | ||
|
49 | create_table "countries", :force => true do |t| |
|
59 | create_table "countries", :force => true do |t| |
|
50 | t.string "name" |
|
60 | t.string "name" |
|
51 | t.datetime "created_at" |
|
61 | t.datetime "created_at" |
You need to be logged in to leave comments.
Login now