Description:
update migration
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r822:f42556ce3209 - - 77 files changed: 120 inserted, 111 deleted

@@ -361,13 +361,13
361 361 spring-watcher-listen (~> 2.0.0)
362 362 sprockets-rails
363 363 sqlite3
364 364 uglifier
365 365 web-console (>= 3.3.0)
366 366 webdrivers
367 367 yaml_db
368 368
369 369 RUBY VERSION
370 370 ruby 3.1.0p0
371 371
372 372 BUNDLED WITH
373 - 2.3.5
373 + 2.3.3
@@ -44,27 +44,37
44 44 cafe@grader:~$ sudo apt-add-repository -y ppa:rael-gc/rvm
45 45 cafe@grader:~$ sudo apt-get update
46 46 cafe@grader:~$ sudo apt-get install rvm
47 47
48 48 We also need to add our user to the rvm group
49 49
50 50 sudo usermod -a -G rvm $USER
51 51
52 52 This is very important.
53 53 1. You have to reboot since RVM change a lots of system.
54 54 2. If you are using GUI version of Ubuntu, be sure to have Gnome Terminal (or any other terminal you are using) perform login every time. This can be done by mark the check box "Run command as a login shell" in Gnome terminal or by adding --login to bash.
55 55
56 - === 3. Install necessary package
56 + === 3. Install necessary package and nodejs
57 +
58 + First, we install required package via apt.
59 +
60 + cafe@grader:~$ sudo apt install libmysqlclient-dev default-jdk unzip php-cli apache2 dirmngr gnupg apache2-dev
57 61
58 - cafe@grader:~$ sudo apt install libmysqlclient-dev default-jdk unzip nodejs php-cli apache2 dirmngr gnupg apache2-dev
62 + Since nodejs that comes with ubuntu 18.04 is very outdated, we need to install it manually. This follow the method outlined in https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 under *Installing Node.js with Apt Using a NodeSource PPA*
63 +
64 + cd ~
65 + curl -sL https://deb.nodesource.com/setup_17.x -o nodesource_setup.sh
66 + sudo bash nodesource_setup.sh
67 + sudo apt install nodejs
68 +
59 69
60 70 === 4. Install cafe-grader
61 71
62 72 First, ensure that RVM is installed correctly.
63 73
64 74 cafe@grader:~$ rvm
65 75
66 76 If you get a result similar to this.
67 77
68 78 Command 'rvm' not found, but there are 21 similar ones.
69 79
70 80 It is very likely that you have not re-login or you are using bash without --login. Please do so and re-read the installation of RVM on Ubuntu https://github.com/rvm/ubuntu_rvm again.
@@ -1,15 +1,15
1 - class CreateUsers < ActiveRecord::Migration
1 + class CreateUsers < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :users do |t|
3 + create_table :users, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :login, :string, :limit => 10
5 5 t.column :full_name, :string
6 6 t.column :hashed_password, :string
7 7 t.column :salt, :string, :limit => 5
8 8 t.column :alias, :string
9 9 end
10 10 # force unique name
11 11 add_index :users, :login, :unique => true
12 12 end
13 13
14 14 def self.down
15 15 drop_table :users
@@ -1,15 +1,15
1 - class CreateProblems < ActiveRecord::Migration
1 + class CreateProblems < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :problems do |t|
3 + create_table :problems, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :name, :string, :limit => 30
5 5 t.column :full_name, :string
6 6 t.column :full_score, :integer
7 7 t.column :date_added, :date
8 8 t.column :available, :boolean
9 9 end
10 10 end
11 11
12 12 def self.down
13 13 drop_table :problems
14 14 end
15 15 end
@@ -1,15 +1,15
1 - class CreateSubmissions < ActiveRecord::Migration
1 + class CreateSubmissions < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :submissions do |t|
3 + create_table :submissions, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :user_id, :integer
5 5 t.column :problem_id, :integer
6 6 t.column :language_id, :integer
7 7 t.column :source, :text
8 8 t.column :binary, :binary
9 9 t.column :submitted_at, :datetime
10 10 t.column :compiled_at, :datetime
11 11 t.column :compiler_message, :text
12 12 t.column :graded_at, :datetime
13 13 t.column :points, :integer
14 14 t.column :grader_comment, :text
15 15 end
@@ -1,15 +1,15
1 - class CreateLanguages < ActiveRecord::Migration
1 + class CreateLanguages < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :languages do |t|
3 + create_table :languages, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :name, :string, :limit => 10
5 5 t.column :pretty_name, :string
6 6 end
7 7
8 8 Language.create(:name => "c", :pretty_name => "C")
9 9 Language.create(:name => "cpp", :pretty_name => "C++")
10 10 Language.create(:name => "pas", :pretty_name => "Pascal")
11 11 end
12 12
13 13 def self.down
14 14 drop_table :languages
15 15 end
@@ -1,9 +1,9
1 - class AddIndexToSubmissions < ActiveRecord::Migration
1 + class AddIndexToSubmissions < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_index :submissions, [:user_id, :problem_id]
4 4 end
5 5
6 6 def self.down
7 7 remove_index :submissions, :column => [:user_id, :problem_id]
8 8 end
9 9 end
@@ -1,19 +1,19
1 - class CreateRoles < ActiveRecord::Migration
1 + class CreateRoles < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :roles do |t|
3 + create_table :roles, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column 'name', :string
5 5 end
6 6
7 - create_table :roles_users, :id => false do |t|
7 + create_table :roles_users, :id => false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
8 8 t.column 'role_id', :integer
9 9 t.column 'user_id', :integer
10 10 end
11 11
12 12 add_index :roles_users, :user_id
13 13 end
14 14
15 15 def self.down
16 16 drop_table :roles_users
17 17 drop_table :roles
18 18 end
19 19 end
@@ -1,21 +1,21
1 - class CreateRights < ActiveRecord::Migration
1 + class CreateRights < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :rights do |t|
3 + create_table :rights, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column 'name', :string
5 5 t.column 'controller', :string
6 6 t.column 'action', :string
7 7 end
8 8
9 - create_table :rights_roles, :id => false do |t|
9 + create_table :rights_roles, :id => false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
10 10 t.column 'right_id', :integer
11 11 t.column 'role_id', :integer
12 12 end
13 13
14 14 add_index :rights_roles, :role_id
15 15 end
16 16
17 17 def self.down
18 18 drop_table :rights_roles
19 19 drop_table :rights
20 20 end
21 21 end
@@ -1,12 +1,12
1 - class CreateTasks < ActiveRecord::Migration
1 + class CreateTasks < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :tasks do |t|
3 + create_table :tasks, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column 'submission_id', :integer
5 5 t.column 'created_at', :datetime
6 6 end
7 7 end
8 8
9 9 def self.down
10 10 drop_table :tasks
11 11 end
12 12 end
@@ -1,15 +1,15
1 - class AddSessions < ActiveRecord::Migration
1 + class AddSessions < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :sessions do |t|
3 + create_table :sessions, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :session_id, :string
5 5 t.column :data, :text
6 6 t.column :updated_at, :datetime
7 7 end
8 8
9 9 add_index :sessions, :session_id
10 10 add_index :sessions, :updated_at
11 11 end
12 12
13 13 def self.down
14 14 drop_table :sessions
15 15 end
@@ -1,13 +1,13
1 - class AddLanguageExt < ActiveRecord::Migration
1 + class AddLanguageExt < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :languages, :ext, :string, :limit => 10
4 4
5 5 Language.reset_column_information
6 6 langs = Language.all
7 7 langs.each do |l|
8 8 l.ext = l.name
9 9 l.save
10 10 end
11 11 end
12 12
13 13 def self.down
@@ -1,9 +1,9
1 - class AddEmailToUsers < ActiveRecord::Migration
1 + class AddEmailToUsers < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :users, :email, :string
4 4 end
5 5
6 6 def self.down
7 7 remove_column :users, :email
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class AddUrlToProblem < ActiveRecord::Migration
1 + class AddUrlToProblem < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :problems, :url, :string
4 4 end
5 5
6 6 def self.down
7 7 remove_column :problems, :url
8 8 end
9 9 end
@@ -1,15 +1,15
1 - class CreateGraderProcesses < ActiveRecord::Migration
1 + class CreateGraderProcesses < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :grader_processes do |t|
3 + create_table :grader_processes, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :ip, :string, :limit => 20
5 5 t.column :pid, :integer
6 6 t.column :mode, :string
7 7 t.column :active, :boolean
8 8 t.timestamps
9 9 end
10 10 add_index :grader_processes, ["ip","pid"]
11 11 end
12 12
13 13 def self.down
14 14 drop_table :grader_processes
15 15 end
@@ -1,13 +1,13
1 - class AddStatusToTasks < ActiveRecord::Migration
1 + class AddStatusToTasks < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :tasks, :status, :integer
4 4 add_column :tasks, :updated_at, :datetime
5 5
6 6 Task.reset_column_information
7 7 Task.all.each do |task|
8 8 task.status_complete
9 9 task.save
10 10 end
11 11 end
12 12
13 13 def self.down
@@ -1,9 +1,9
1 - class AddTaskToGraderProcess < ActiveRecord::Migration
1 + class AddTaskToGraderProcess < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :grader_processes, :task_id, :integer
4 4 end
5 5
6 6 def self.down
7 7 remove_column :grader_processes, :task_id
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class RenameGraderProcessColumnIpToHost < ActiveRecord::Migration
1 + class RenameGraderProcessColumnIpToHost < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 rename_column :grader_processes, :ip, :host
4 4 end
5 5
6 6 def self.down
7 7 rename_column :grader_processes, :host, :ip
8 8 end
9 9 end
@@ -1,13 +1,13
1 - class AddNumberToSubmissions < ActiveRecord::Migration
1 + class AddNumberToSubmissions < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :submissions, :number, :integer
4 4
5 5 # add number field for all records
6 6 Submission.reset_column_information
7 7
8 8 last_user_id = nil
9 9 last_problem_id = nil
10 10 current_number = 0
11 11
12 12 Submission.order('user_id, problem_id, submitted_at').each do |submission|
13 13 if submission.user_id==last_user_id and submission.problem_id==last_problem_id
@@ -1,25 +1,24
1 - class CreateTestRequests < ActiveRecord::Migration
1 + class CreateTestRequests < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :test_requests do |t|
3 + create_table :test_requests, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :user_id, :integer
5 5 t.column :problem_id, :integer
6 6 t.column :submission_id, :integer
7 7 t.column :input_file_name, :string
8 8 t.column :output_file_name, :string
9 9 t.column :running_stat, :string
10 10
11 11 # these are similar to tasks
12 12 t.column :status, :integer
13 - t.column :updated_at, :datetime
14 13
15 14 # these are intentionally similar to submissions
16 15 t.column :submitted_at, :datetime
17 16 t.column :compiled_at, :datetime
18 17 t.column :compiler_message, :string
19 18 t.column :graded_at, :datetime
20 19 t.column :grader_comment, :string
21 20 t.timestamps
22 21 end
23 22 add_index :test_requests, [:user_id, :problem_id]
24 23 end
25 24
@@ -1,9 +1,9
1 - class ChangeCompilerMessageTypeTestRequest < ActiveRecord::Migration
1 + class ChangeCompilerMessageTypeTestRequest < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 change_column :test_requests, :compiler_message, :text
4 4 end
5 5
6 6 def self.down
7 7 change_column :test_requests, :compiler_message, :string
8 8 end
9 9 end
@@ -1,14 +1,14
1 - class CreateConfigurations < ActiveRecord::Migration
1 + class CreateConfigurations < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :configurations do |t|
3 + create_table :configurations, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :key, :string
5 5 t.column :value_type, :string
6 6 t.column :value, :string
7 7 t.timestamps
8 8 end
9 9 end
10 10
11 11 def self.down
12 12 drop_table :configurations
13 13 end
14 14 end
@@ -1,13 +1,13
1 - class AddRunstatColumnsToTestRequest < ActiveRecord::Migration
1 + class AddRunstatColumnsToTestRequest < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :test_requests, :running_time, :float
4 4 add_column :test_requests, :exit_status, :string
5 5 add_column :test_requests, :memory_usage, :integer
6 6 end
7 7
8 8 def self.down
9 9 remove_column :test_requests, :running_time
10 10 remove_column :test_requests, :exit_status
11 11 remove_column :test_requests, :memory_usage
12 12 end
13 13 end
@@ -1,15 +1,15
1 - class CreateSites < ActiveRecord::Migration
1 + class CreateSites < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :sites do |t|
3 + create_table :sites, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.string :name
5 5 t.boolean :started
6 6 t.datetime :start_time
7 7
8 8 t.timestamps
9 9 end
10 10 end
11 11
12 12 def self.down
13 13 drop_table :sites
14 14 end
15 15 end
@@ -1,13 +1,13
1 - class AddSiteToUserAndAddDefaultSite < ActiveRecord::Migration
1 + class AddSiteToUserAndAddDefaultSite < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 default_site = Site.new({:name => 'default',
4 4 :started => false})
5 5 default_site.save!
6 6
7 7 add_column :users, :site_id, :integer
8 8 User.reset_column_information
9 9
10 10 User.all.each do |user|
11 11
12 12 class << user
13 13 def valid?
@@ -1,9 +1,9
1 - class AddBodyToProblems < ActiveRecord::Migration
1 + class AddBodyToProblems < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :problems, :body, :text
4 4 end
5 5
6 6 def self.down
7 7 remove_column :problems, :body
8 8 end
9 9 end
@@ -1,13 +1,13
1 - class CreateDescriptions < ActiveRecord::Migration
1 + class CreateDescriptions < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :descriptions do |t|
3 + create_table :descriptions, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :body, :text
5 5 t.column :markdowned, :boolean
6 6 t.timestamps
7 7 end
8 8 end
9 9
10 10 def self.down
11 11 drop_table :descriptions
12 12 end
13 13 end
@@ -1,13 +1,13
1 - class RefactorProblemBodyToDescription < ActiveRecord::Migration
1 + class RefactorProblemBodyToDescription < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :problems, :description_id, :integer
4 4 Problem.reset_column_information
5 5
6 6 Problem.all.each do |problem|
7 7 if problem.body!=nil
8 8 description = Description.new
9 9 description.body = problem.body
10 10 description.markdowned = false
11 11 description.save
12 12 problem.description_id = description.id
13 13 problem.save
@@ -1,13 +1,13
1 - class AddTestAllowedToProblems < ActiveRecord::Migration
1 + class AddTestAllowedToProblems < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :problems, :test_allowed, :boolean
4 4 Problem.reset_column_information
5 5
6 6 Problem.all.each do |problem|
7 7 problem.test_allowed = true
8 8 problem.save
9 9 end
10 10 end
11 11
12 12 def self.down
13 13 remove_column :problems, :test_allowed
@@ -1,15 +1,15
1 - class CreateAnnouncements < ActiveRecord::Migration
1 + class CreateAnnouncements < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :announcements do |t|
3 + create_table :announcements, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.string :author
5 5 t.text :body
6 6 t.boolean :published
7 7
8 8 t.timestamps
9 9 end
10 10 end
11 11
12 12 def self.down
13 13 drop_table :announcements
14 14 end
15 15 end
@@ -1,11 +1,11
1 - class AddSupportsForOutputOnlyProblems < ActiveRecord::Migration
1 + class AddSupportsForOutputOnlyProblems < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :submissions, :source_filename, :string
4 4 add_column :problems, :output_only, :boolean
5 5 end
6 6
7 7 def self.down
8 8 remove_column :submissions, :source_filename
9 9 remove_column :problems, :output_only
10 10 end
11 11 end
@@ -1,15 +1,15
1 - class CreateMessages < ActiveRecord::Migration
1 + class CreateMessages < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :messages do |t|
3 + create_table :messages, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column "sender_id", :integer
5 5 t.column "receiver_id", :integer
6 6 t.column "replying_message_id", :integer
7 7 t.column "body", :text
8 8 t.column "replied", :boolean # this is for efficiency
9 9
10 10 t.timestamps
11 11 end
12 12 end
13 13
14 14 def self.down
15 15 drop_table :messages
@@ -1,9 +1,9
1 - class AddTaskTypeToGraderProcesses < ActiveRecord::Migration
1 + class AddTaskTypeToGraderProcesses < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column 'grader_processes', 'task_type', :string
4 4 end
5 5
6 6 def self.down
7 7 remove_column 'grader_processes', 'task_type'
8 8 end
9 9 end
@@ -1,12 +1,12
1 - class CreateCountries < ActiveRecord::Migration
1 + class CreateCountries < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :countries do |t|
3 + create_table :countries, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column :name, :string
5 5 t.timestamps
6 6 end
7 7 end
8 8
9 9 def self.down
10 10 drop_table :countries
11 11 end
12 12 end
@@ -1,13 +1,13
1 - class AddCountryToSitesAndUsers < ActiveRecord::Migration
1 + class AddCountryToSitesAndUsers < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column 'sites', 'country_id', :integer
4 4 add_column 'sites', 'password', :string
5 5
6 6 add_column 'users', 'country_id', :integer
7 7 end
8 8
9 9 def self.down
10 10 remove_column 'users', 'country_id'
11 11
12 12 remove_column 'sites', 'country_id'
13 13 remove_column 'sites', 'password'
@@ -1,9 +1,9
1 - class AddFrontpageFlagToAnnouncement < ActiveRecord::Migration
1 + class AddFrontpageFlagToAnnouncement < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :announcements, "frontpage", :boolean, :default => 0
4 4 end
5 5
6 6 def self.down
7 7 remove_column :announcements, "frontpage"
8 8 end
9 9 end
@@ -1,13 +1,13
1 - class AddActivatedToUsers < ActiveRecord::Migration
1 + class AddActivatedToUsers < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :users, :activated, :boolean, :default => 0
4 4
5 5 User.reset_column_information
6 6
7 7 User.all.each do |user|
8 8
9 9 # disable validation
10 10 class <<user
11 11 def valid?
12 12 return true
13 13 end
@@ -1,9 +1,9
1 - class AddTimestampsToUsers < ActiveRecord::Migration
1 + class AddTimestampsToUsers < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_timestamps :users
4 4 end
5 5
6 6 def self.down
7 7 remove_timestamps :users
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class ChangeUserLoginStringLimit < ActiveRecord::Migration
1 + class ChangeUserLoginStringLimit < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 execute "ALTER TABLE `users` CHANGE `login` `login` VARCHAR( 50 )"
4 4 end
5 5
6 6 def self.down
7 7 # don't have to revert
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class AddContestFlagToAnnouncements < ActiveRecord::Migration
1 + class AddContestFlagToAnnouncements < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :announcements, :contest_only, :boolean, :default => false
4 4 end
5 5
6 6 def self.down
7 7 remove_column :announcements, :contest_only
8 8 end
9 9 end
@@ -1,13 +1,13
1 - class AddCommonExtToLanguages < ActiveRecord::Migration
1 + class AddCommonExtToLanguages < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 # language.common_ext is a comma-separated list of common file
4 4 # extensions.
5 5 add_column :languages, :common_ext, :string
6 6
7 7 # updating table information
8 8 Language.reset_column_information
9 9 common_ext = {
10 10 'c' => 'c',
11 11 'cpp' => 'cpp,cc',
12 12 'pas' => 'pas'
13 13 }
@@ -1,9 +1,9
1 - class AddTerminatedToGraderProcesses < ActiveRecord::Migration
1 + class AddTerminatedToGraderProcesses < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :grader_processes, :terminated, :boolean
4 4 end
5 5
6 6 def self.down
7 7 remove_column :grader_processes, :terminated
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class AddTitleToAnnouncements < ActiveRecord::Migration
1 + class AddTitleToAnnouncements < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :announcements, :title, :string
4 4 end
5 5
6 6 def self.down
7 7 remove_column :announcements, :title
8 8 end
9 9 end
@@ -1,15 +1,15
1 - class CreateTestPairs < ActiveRecord::Migration
1 + class CreateTestPairs < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :test_pairs do |t|
3 + create_table :test_pairs, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.integer :problem_id
5 5 t.text :input
6 6 t.text :solution
7 7
8 8 t.timestamps
9 9 end
10 10 end
11 11
12 12 def self.down
13 13 drop_table :test_pairs
14 14 end
15 15 end
@@ -1,9 +1,9
1 - class AddDescriptionToConfig < ActiveRecord::Migration
1 + class AddDescriptionToConfig < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :configurations, :description, :text
4 4 end
5 5
6 6 def self.down
7 7 remove_column :configurations, :description
8 8 end
9 9 end
@@ -1,14 +1,14
1 - class CreateUserContestStats < ActiveRecord::Migration
1 + class CreateUserContestStats < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :user_contest_stats do |t|
3 + create_table :user_contest_stats, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.integer :user_id
5 5 t.timestamp :started_at
6 6
7 7 t.timestamps
8 8 end
9 9 end
10 10
11 11 def self.down
12 12 drop_table :user_contest_stats
13 13 end
14 14 end
@@ -1,11 +1,11
1 - class ChangeInputSolutionFieldLimitInTestPair < ActiveRecord::Migration
1 + class ChangeInputSolutionFieldLimitInTestPair < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 change_column :test_pairs, :input, :text, :limit => 1.megabytes
4 4 change_column :test_pairs, :solution, :text, :limit => 1.megabytes
5 5 end
6 6
7 7 def self.down
8 8 change_column :test_pairs, :input, :text
9 9 change_column :test_pairs, :solution, :text
10 10 end
11 11 end
@@ -1,14 +1,14
1 - class CreateContests < ActiveRecord::Migration
1 + class CreateContests < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :contests do |t|
3 + create_table :contests, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.string :title
5 5 t.boolean :enabled
6 6
7 7 t.timestamps
8 8 end
9 9 end
10 10
11 11 def self.down
12 12 drop_table :contests
13 13 end
14 14 end
@@ -1,12 +1,12
1 - class CreateContestsUsersJoinTable < ActiveRecord::Migration
1 + class CreateContestsUsersJoinTable < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :contests_users, :id => false do |t|
3 + create_table :contests_users, :id => false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.integer :contest_id
5 5 t.integer :user_id
6 6 end
7 7 end
8 8
9 9 def self.down
10 10 drop_table :contests_users
11 11 end
12 12 end
@@ -1,12 +1,12
1 - class CreateContestsProblemsJoinTable < ActiveRecord::Migration
1 + class CreateContestsProblemsJoinTable < ActiveRecord::Migration[4.2]
2 2 def self.up
3 - create_table :contests_problems, :id => false do |t|
3 + create_table :contests_problems, :id => false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.integer :contest_id
5 5 t.integer :problem_id
6 6 end
7 7 end
8 8
9 9 def self.down
10 10 drop_table :contests_problems
11 11 end
12 12 end
@@ -1,9 +1,9
1 - class AddDescriptionFilenameToProblems < ActiveRecord::Migration
1 + class AddDescriptionFilenameToProblems < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :problems, :description_filename, :string
4 4 end
5 5
6 6 def self.down
7 7 remove_column :problems, :description_filename
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class AddNameToContests < ActiveRecord::Migration
1 + class AddNameToContests < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :contests, :name, :string
4 4 end
5 5
6 6 def self.down
7 7 remove_column :contests, :name
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class AddForcedLogoutToUserContestStat < ActiveRecord::Migration
1 + class AddForcedLogoutToUserContestStat < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :user_contest_stats, :forced_logout, :boolean
4 4 end
5 5
6 6 def self.down
7 7 remove_column :user_contest_stats, :forced_logout, :boolean
8 8 end
9 9 end
@@ -1,9 +1,9
1 - class AddNotesToAnnouncements < ActiveRecord::Migration
1 + class AddNotesToAnnouncements < ActiveRecord::Migration[4.2]
2 2 def self.up
3 3 add_column :announcements, :notes, :string
4 4 end
5 5
6 6 def self.down
7 7 remove_column :announcements, :notes
8 8 end
9 9 end
@@ -1,5 +1,5
1 - class RenameConfigurationsToGraderConfigurations < ActiveRecord::Migration
1 + class RenameConfigurationsToGraderConfigurations < ActiveRecord::Migration[4.2]
2 2 def change
3 3 rename_table 'configurations', 'grader_configurations'
4 4 end
5 5 end
@@ -1,7 +1,7
1 - class AddMoreDetailToSubmission < ActiveRecord::Migration
1 + class AddMoreDetailToSubmission < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_column :submissions, :max_runtime, :float
4 4 add_column :submissions, :peak_memory, :integer
5 5 add_column :submissions, :effective_code_length, :integer
6 6 end
7 7 end
@@ -1,10 +1,10
1 - class CreateLogins < ActiveRecord::Migration
1 + class CreateLogins < ActiveRecord::Migration[4.2]
2 2 def change
3 - create_table :logins do |t|
3 + create_table :logins, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.string :user_id
5 5 t.string :ip_address
6 6
7 7 t.timestamps
8 8 end
9 9 end
10 10 end
@@ -1,5 +1,5
1 - class AddSectionToUsers < ActiveRecord::Migration
1 + class AddSectionToUsers < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_column :users, :section, :string
4 4 end
5 5 end
@@ -1,5 +1,5
1 - class AddIpToSubmissions < ActiveRecord::Migration
1 + class AddIpToSubmissions < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_column :submissions, :ip_address, :string
4 4 end
5 5 end
@@ -1,6 +1,6
1 - class AddMoreToUsers < ActiveRecord::Migration
1 + class AddMoreToUsers < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_column :users, :enabled, :boolean, default: 1
4 4 add_column :users, :remark, :string
5 5 end
6 6 end
@@ -1,9 +1,9
1 - class ChangeUseridOnLogin < ActiveRecord::Migration
1 + class ChangeUseridOnLogin < ActiveRecord::Migration[4.2]
2 2 def up
3 3 change_column :logins, :user_id, :integer
4 4 end
5 5
6 6 def down
7 7 change_column :logins, :user_id, :string
8 8 end
9 9 end
@@ -1,10 +1,10
1 - class CreateSubmissionViewLogs < ActiveRecord::Migration
1 + class CreateSubmissionViewLogs < ActiveRecord::Migration[4.2]
2 2 def change
3 - create_table :submission_view_logs do |t|
3 + create_table :submission_view_logs, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.integer :user_id
5 5 t.integer :submission_id
6 6
7 7 t.timestamps
8 8 end
9 9 end
10 10 end
@@ -1,5 +1,5
1 - class AddLastIpToUser < ActiveRecord::Migration
1 + class AddLastIpToUser < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_column :users, :last_ip, :string
4 4 end
5 5 end
@@ -1,10 +1,10
1 - class CreateHeartBeats < ActiveRecord::Migration
1 + class CreateHeartBeats < ActiveRecord::Migration[4.2]
2 2 def change
3 - create_table :heart_beats do |t|
3 + create_table :heart_beats, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.column 'user_id',:integer
5 5 t.column 'ip_address',:string
6 6
7 7 t.timestamps
8 8 end
9 9 end
10 10 end
@@ -1,5 +1,5
1 - class AddStatusToHeartBeat < ActiveRecord::Migration
1 + class AddStatusToHeartBeat < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_column :heart_beats, :status, :string
4 4 end
5 5 end
@@ -1,9 +1,9
1 - class AddMoreConfig < ActiveRecord::Migration
1 + class AddMoreConfig < ActiveRecord::Migration[4.2]
2 2 def up
3 3 GraderConfiguration.create key: 'right.bypass_agreement', value_type: 'boolean', value:'true', description:'When false, a check box to accept license agreement appear at login and the user must click accept'
4 4 end
5 5
6 6 def down
7 7
8 8 end
9 9 end
@@ -1,10 +1,10
1 - class UpdateHeartBeat < ActiveRecord::Migration
1 + class UpdateHeartBeat < ActiveRecord::Migration[4.2]
2 2 def up
3 3 GraderConfiguration.create key: 'right.heartbeat_response', value_type: 'string', value:'OK', description:'Heart beat response text'
4 4 add_index :heart_beats, :updated_at
5 5 end
6 6
7 7 def down
8 8 remove_index :heart_beats, :updated_at
9 9 end
10 10 end
@@ -1,9 +1,9
1 - class ModifyGraderProcess < ActiveRecord::Migration
1 + class ModifyGraderProcess < ActiveRecord::Migration[4.2]
2 2 def up
3 3 change_column :grader_processes, :host, :string
4 4 end
5 5
6 6 def down
7 7 change_column :grader_processes, :host, :string, limit: 20
8 8 end
9 9 end
@@ -1,15 +1,15
1 - class CreateTestcases < ActiveRecord::Migration
1 + class CreateTestcases < ActiveRecord::Migration[4.2]
2 2 def change
3 - create_table :testcases do |t|
3 + create_table :testcases, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.references :problem
5 5 t.integer :num
6 6 t.integer :group
7 7 t.integer :score
8 8 t.text :input
9 9 t.text :sol
10 10
11 11 t.timestamps
12 12 end
13 13 add_index :testcases, :problem_id
14 14 end
15 15 end
@@ -1,13 +1,13
1 - class AddConfigViewTest < ActiveRecord::Migration
1 + class AddConfigViewTest < ActiveRecord::Migration[4.2]
2 2 def up
3 3 GraderConfiguration.create key: 'right.view_testcase', value_type: 'boolean', value:'true', description:'When true, any user can view/download test data'
4 4 #uglily and dirtily and shamelessly check other config and inifialize
5 5 GraderConfiguration.where(key: 'right.user_hall_of_fame').first_or_create(value_type: 'boolean', value: 'false',
6 6 description: 'If true, any user can access hall of fame page.')
7 7 GraderConfiguration.where(key: 'right.multiple_ip_login').first_or_create(value_type: 'boolean', value: 'false',
8 8 description: 'When change from true to false, a user can login from the first IP they logged into afterward.')
9 9 GraderConfiguration.where(key: 'right.user_view_submission').first_or_create(value_type: 'boolean', value: 'false',
10 10 description: 'If true, any user can view submissions of every one.')
11 11 end
12 12
13 13 def down
@@ -1,6 +1,6
1 - class ChangeTestcaseSize < ActiveRecord::Migration
1 + class ChangeTestcaseSize < ActiveRecord::Migration[4.2]
2 2 def change
3 3 change_column :testcases, :input, :text, :limit => 4294967295
4 4 change_column :testcases, :sol, :text, :limit => 4294967295
5 5 end
6 6 end
@@ -1,5 +1,5
1 - class AddViewTestcaseToProblem < ActiveRecord::Migration
1 + class AddViewTestcaseToProblem < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_column :problems, :view_testcase, :bool
4 4 end
5 5 end
@@ -1,5 +1,5
1 - class AddIndexToTask < ActiveRecord::Migration
1 + class AddIndexToTask < ActiveRecord::Migration[4.2]
2 2 def change
3 3 add_index :tasks, :submission_id
4 4 end
5 5 end
@@ -1,9 +1,9
1 - class AddHeartBeatFull < ActiveRecord::Migration
1 + class AddHeartBeatFull < ActiveRecord::Migration[4.2]
2 2 def up
3 3 GraderConfiguration.create key: 'right.heartbeat_response_full', value_type: 'string', value:'RESTART', description:'Heart beat response text when user got full score (set this value to the empty string to disable this feature)'
4 4 end
5 5
6 6 def down
7 7
8 8 end
9 9 end
@@ -1,26 +1,26
1 - class CreateGroups < ActiveRecord::Migration
1 + class CreateGroups < ActiveRecord::Migration[4.2]
2 2
3 3 def change
4 - create_table :groups do |t|
4 + create_table :groups, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
5 5 t.string :name
6 6 t.string :description
7 7 end
8 8
9 - create_join_table :groups, :users do |t|
9 + create_join_table :groups, :users, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
10 10 # t.index [:group_id, :user_id]
11 11 t.index [:user_id, :group_id]
12 12 end
13 13
14 - create_join_table :problems, :groups do |t|
14 + create_join_table :problems, :groups, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
15 15 # t.index [:problem_id, :group_id]
16 16 t.index [:group_id, :problem_id]
17 17 end
18 18
19 19 reversible do |change|
20 20 change.up do
21 21 GraderConfiguration.where(key: 'system.use_problem_group').first_or_create(value_type: 'boolean', value: 'false',
22 22 description: 'If true, available problem to the user will be only ones associated with the group of the user');
23 23 end
24 24
25 25 change.down do
26 26 GraderConfiguration.where(key: 'system.use_problem_group').destroy_all
@@ -1,11 +1,11
1 - class CreateTags < ActiveRecord::Migration
1 + class CreateTags < ActiveRecord::Migration[4.2]
2 2 def change
3 - create_table :tags do |t|
3 + create_table :tags, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.string :name, null: false
5 5 t.text :description
6 6 t.boolean :public
7 7
8 8 t.timestamps null: false
9 9 end
10 10 end
11 11 end
@@ -1,10 +1,10
1 - class CreateProblemTags < ActiveRecord::Migration
1 + class CreateProblemTags < ActiveRecord::Migration[4.2]
2 2 def change
3 - create_table :problems_tags do |t|
3 + create_table :problems_tags, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
4 4 t.references :problem, index: true, foreign_key: true
5 5 t.references :tag, index: true, foreign_key: true
6 6
7 7 t.index [:problem_id,:tag_id], unique: true
8 8 end
9 9 end
10 10 end
You need to be logged in to leave comments. Login now