Initial import

This commit is contained in:
2008-03-02 16:04:34 -03:00
commit 5e4951fa47
798 changed files with 59730 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
class CreateAttachments < ActiveRecord::Migration
def self.up
create_table :attachments do |t|
t.column :file_name, :string
t.column :content_type, :string
t.column :last_modified, :datetime
t.column :description, :text
t.column :size, :int
end
end
def self.down
drop_table :attachments
end
end

View File

@@ -0,0 +1,32 @@
class CreateProfessorsAndCourses < ActiveRecord::Migration
def self.up
# Tabela de professores
create_table :professors do |t|
t.column :name, :string, :null => false
end
# Tabela de disciplinas
create_table :courses do |t|
t.column :short_name, :string, :null => false
t.column :full_name, :string, :null => false
t.column :description, :text, :null => false
end
# Relacionamento
create_table :courses_professors, :id => false do |t|
t.column :professor_id, :integer
t.column :course_id, :integer
end
# Adiciona o campo disciplina aos objetos do repositorio
add_column :attachments, :course_id, :integer
end
def self.down
drop_table :professors
drop_table :courses
drop_table :courses_professors
remove_column :attachments, :course_id
end
end

View File

@@ -0,0 +1,16 @@
class CreateMessages < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.column :title, :string
t.column :body, :text, :null => false
t.column :timestamp, :timestamp, :null => false
t.column :message_type, :int, :null => false
#t.column :sender_id, :int, :null => false
t.column :receiver_id, :int
end
end
def self.down
drop_table :messages
end
end

View File

@@ -0,0 +1,21 @@
class CreateWiki < ActiveRecord::Migration
def self.up
create_table :wiki_pages do |t|
t.column :course_id, :int
t.column :title, :string, :null => false
end
create_table :wiki_versions do |t|
t.column :cache_html, :text
t.column :content, :text, :null => false
t.column :created_on, :timestamp, :null => false
t.column :user_id, :int
t.column :wiki_page_id, :int
end
end
def self.down
drop_table :wiki_pages
drop_table :wiki_versions
end
end

View File

@@ -0,0 +1,16 @@
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.column :title, :string, :null => false
t.column :date, :date, :null => false
t.column :time, :time, :null => false
t.column :created_by, :integer, :null => false
t.column :course_id, :integer, :null => false, :default => 0
t.column :description, :text
end
end
def self.down
drop_table :events
end
end

View File

@@ -0,0 +1,31 @@
class SampleCourse < ActiveRecord::Migration
def self.up
# Cria um novo curso
c = Course.new
c.full_name = c.short_name = "Métodos Numéricos II"
c.description = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." +
"Etiam eu quam pharetra tellus scelerisque vehicula. Donec non sem. In hac habitasse" +
"platea dictumst. Integer dictum leo eget sem. Vestibulum feugiat ligula vel massa." +
"Praesent mattis. Etiam neque lorem, tincidunt eget, interdum in, malesuada et, velit." +
"Integer sapien mi, consequat vel, tempus sed, vehicula sit amet, quam."
c.save
# Cria duas paginas wiki
wp_ementa = WikiPage.new(:title => "Ementa")
wp_notas = WikiPage.new(:title => "Notas de Aula")
c.wiki_pages << wp_ementa
c.wiki_pages << wp_notas
# Cria uma versao para cada pagina do wiki
wv_ementa = WikiVersion.new(:content => "Blank page")
wv_notas = WikiVersion.new(:content => "Blank page")
wp_ementa.wiki_versions << wv_ementa
wp_notas.wiki_versions << wv_notas
end
def self.down
end
end

View File

@@ -0,0 +1,15 @@
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :login, :string
t.column :hashed_password, :string
t.column :email, :string
t.column :salt, :string
t.column :created_at, :datetime
end
end
def self.down
drop_table :users
end
end

15
db/migrate/008_diff.rb Normal file
View File

@@ -0,0 +1,15 @@
class Diff < ActiveRecord::Migration
def self.up
add_column :wiki_versions, :root, :boolean, :default => true, :null => false
add_column :wiki_pages, :diff_countdown, :integer, :default => 0, :null => false
WikiVersion.find(:all).each do |version|
version.update_attribute(:root, false) if version.cache_html == nil
end
end
def self.down
remove_column :wiki_versions, :root
remove_column :wiki_pages, :diff_countdown
end
end

10
db/migrate/009_cache.rb Normal file
View File

@@ -0,0 +1,10 @@
class Cache < ActiveRecord::Migration
# Remove a coluna de cache
def self.up
remove_column :wiki_versions, "cache_html"
end
def self.down
add_column :wiki_versions, "cache_html", :text
end
end

View File

@@ -0,0 +1,24 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class MessageSender < ActiveRecord::Migration
def self.up
add_column :messages, :sender_id, :int, :null => false
add_column :users, :name, :string, :null => false, :default => ''
end
def self.down
remove_column :messages, :sender_id
remove_column :users, :name
end
end

View File

@@ -0,0 +1,22 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class UniqueShortName < ActiveRecord::Migration
def self.up
add_index :courses, :short_name, :unique => true
end
def self.down
remove_index :courses, :short_name
end
end

View File

@@ -0,0 +1,13 @@
class LinkUserCourse < ActiveRecord::Migration
def self.up
# Relacionamento
create_table :courses_users, :id => false do |t|
t.column :user_id, :integer
t.column :course_id, :integer
end
end
def self.down
drop_table :courses_users
end
end

View File

@@ -0,0 +1,9 @@
class AddPrefColor < ActiveRecord::Migration
def self.up
add_column :users, :pref_color, :integer
end
def self.down
remove_column :users, :pref_color
end
end

View File

@@ -0,0 +1,9 @@
class DefaultPrefColor < ActiveRecord::Migration
def self.up
change_column :users, :pref_color, :integer, :default => 6
end
def self.down
change_column :users, :pref_color, :integer
end
end

View File

@@ -0,0 +1,9 @@
class AddWikiVersionDescription < ActiveRecord::Migration
def self.up
add_column :wiki_versions, :description, :text
end
def self.down
remove_column :wiki_versions, :description
end
end

View File

@@ -0,0 +1,16 @@
class CreateSessions < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
end
def self.down
drop_table :sessions
end
end

View File

@@ -0,0 +1,145 @@
class CreateForum < ActiveRecord::Migration
def self.up
create_table "forum_forums", :force => true do |t|
t.string "name"
t.string "description"
t.integer "topics_count", :default => 0
t.integer "posts_count", :default => 0
t.integer "position"
t.text "description_html"
end
create_table "forum_logged_exceptions", :force => true do |t|
t.string "exception_class"
t.string "controller_name"
t.string "action_name"
t.string "message"
t.text "backtrace"
t.text "environment"
t.text "request"
t.datetime "created_at"
end
create_table "forum_moderatorships", :force => true do |t|
t.integer "forum_id"
t.integer "user_id"
end
add_index "forum_moderatorships", ["forum_id"], :name => "index_moderatorships_on_forum_id"
create_table "forum_monitorships", :force => true do |t|
t.integer "topic_id"
t.integer "user_id"
t.boolean "active", :default => true
end
create_table "forum_open_id_authentication_associations", :force => true do |t|
t.binary "server_url"
t.string "handle"
t.binary "secret"
t.integer "issued"
t.integer "lifetime"
t.string "assoc_type"
end
create_table "forum_open_id_authentication_nonces", :force => true do |t|
t.string "nonce"
t.integer "created"
end
create_table "forum_open_id_authentication_settings", :force => true do |t|
t.string "setting"
t.binary "value"
end
create_table "forum_posts", :force => true do |t|
t.integer "user_id"
t.integer "topic_id"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "forum_id"
t.text "body_html"
end
add_index "forum_posts", ["topic_id", "created_at"], :name => "index_posts_on_topic_id"
add_index "forum_posts", ["user_id", "created_at"], :name => "index_posts_on_user_id"
add_index "forum_posts", ["forum_id", "created_at"], :name => "index_posts_on_forum_id"
create_table "forum_schema_info", :id => false, :force => true do |t|
t.integer "version"
end
create_table "forum_sessions", :force => true do |t|
t.string "session_id"
t.text "data"
t.datetime "updated_at"
t.integer "user_id"
end
add_index "forum_sessions", ["session_id"], :name => "sessions_session_id_index"
create_table "forum_topics", :force => true do |t|
t.integer "forum_id"
t.integer "user_id"
t.string "title"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "hits", :default => 0
t.integer "sticky", :default => 0
t.integer "posts_count", :default => 0
t.datetime "replied_at"
t.boolean "locked", :default => false
t.integer "replied_by"
t.integer "last_post_id"
end
add_index "forum_topics", ["forum_id", "replied_at"], :name => "index_topics_on_forum_id_and_replied_at"
add_index "forum_topics", ["forum_id", "sticky", "replied_at"], :name => "index_topics_on_sticky_and_replied_at"
add_index "forum_topics", ["forum_id"], :name => "index_topics_on_forum_id"
create_table "forum_users", :force => true do |t|
t.string "login"
t.string "email"
t.string "password_hash"
t.datetime "created_at"
t.datetime "last_login_at"
t.boolean "admin"
t.integer "posts_count", :default => 0
t.datetime "last_seen_at"
t.string "display_name"
t.datetime "updated_at"
t.string "website"
t.string "login_key"
t.datetime "login_key_expires_at"
t.boolean "activated", :default => false
t.string "bio"
t.text "bio_html"
t.string "openid_url"
end
add_index "forum_users", ["posts_count"], :name => "index_users_on_posts_count"
add_index "forum_users", ["last_seen_at"], :name => "index_users_on_last_seen_at"
time = Time.now.strftime("%Y-%m-%d %H:%M:%S")
execute "insert into forum_users (id, login, email, created_at," +
"last_login_at, admin, display_name, updated_at, website," +
"activated) select u.id, u.login, u.email, '#{time}'," +
"'#{time}', 1, u.name, '#{time}', '', 1 from users u"
end
def self.down
drop_table :forum_forums
drop_table :forum_logged_exceptions
drop_table :forum_moderatorships
drop_table :forum_monitorships
drop_table :forum_open_id_authentication_associations
drop_table :forum_open_id_authentication_nonces
drop_table :forum_open_id_authentication_settings
drop_table :forum_posts
drop_table :forum_schema_info
drop_table :forum_sessions
drop_table :forum_topics
drop_table :forum_users
end
end

View File

@@ -0,0 +1,17 @@
class DropProfessors < ActiveRecord::Migration
def self.up
drop_table :professors
drop_table :courses_professors
end
def self.down
create_table :professors do |t|
t.column :name, :string, :null => false
end
create_table :courses_professors, :id => false do |t|
t.column :professor_id, :integer
t.column :course_id, :integer
end
end
end

View File

@@ -0,0 +1,36 @@
class ActsAsVersioned < ActiveRecord::Migration
def self.up
drop_table :wiki_pages
drop_table :wiki_versions
create_table :wiki_pages, :force => true do |t|
t.integer :course_id
t.integer :user_id
t.integer :version, :null => false
t.string :description
t.string :title
t.text :content, :null => false
t.timestamps
end
WikiPage.create_versioned_table
end
def self.down
WikiPage.drop_versioned_table
create_table "wiki_pages", :force => true do |t|
t.integer "course_id"
t.string "title", :null => false
t.integer "diff_countdown", :default => 0, :null => false
end
create_table "wiki_versions", :force => true do |t|
t.text "content", :null => false
t.datetime "created_on", :null => false
t.integer "user_id"
t.integer "wiki_page_id"
t.boolean "root", :default => true, :null => false
t.text "description"
end
end
end

View File

@@ -0,0 +1,24 @@
class MessageInheritance < ActiveRecord::Migration
def self.up
add_column :messages, :type, :string
Message.find(:all).each do |m|
case m.message_type
when -1: m[:type] = "UserShoutboxMessage"
when 0: m[:type] = "CourseShoutboxMessage"
when 3: m[:type] = "News"
else m[:type] = "Message"
end
m.save!
end
remove_column :messages, :message_type
end
def self.down
add_column :messages, :message_type, :integer
remove_column :messages, :type
end
end

View File

@@ -0,0 +1,22 @@
class UserDisplayName < ActiveRecord::Migration
def self.up
add_column :users, :display_name, :string
add_column :users, :description, :text
add_column :users, :last_seen, :datetime
User.find(:all).each do |user|
user.display_name = user.login
user.last_seen = Time.now
user.save!
end
change_column :users, :display_name, :string, :null => false
change_column :users, :last_seen, :datetime, :null => false
end
def self.down
remove_column :users, :display_name
remove_column :users, :description
remove_column :users, :last_seen
end
end

View File

@@ -0,0 +1,14 @@
class TokenLogin < ActiveRecord::Migration
def self.up
add_column :users, :login_key, :string
User.find(:all).each do |user|
user.login_key = Digest::SHA1.hexdigest(Time.now.to_s + user.password.to_s + rand(123456789).to_s).to_s
user.save!
end
end
def self.down
remove_column :users, :login_key
end
end

View File

@@ -0,0 +1,16 @@
class WikiPageOrder < ActiveRecord::Migration
def self.up
add_column :wiki_pages, :position, :integer
add_column :wiki_page_versions, :position, :integer
Course.find(:all).each do |course|
course.wiki_pages.each_with_index do |wp, i|
wp.position = i+1
wp.save!
end
end
end
def self.down
remove_column :wiki_pages, :position
end
end

View File

@@ -0,0 +1,15 @@
class Paranoid < ActiveRecord::Migration
def self.up
add_column :wiki_pages, :deleted_at, :timestamp
add_column :messages, :deleted_at, :timestamp
add_column :events, :deleted_at, :timestamp
add_column :attachments, :deleted_at, :timestamp
end
def self.down
remove_column :wiki_pages, :deleted_at
remove_column :messages, :deleted_at
remove_column :events, :deleted_at
remove_column :attachments, :deleted_at
end
end

View File

@@ -0,0 +1,16 @@
class CreateLogEntries < ActiveRecord::Migration
def self.up
create_table :log_entries do |t|
t.datetime :created_at
t.integer :course_id, :null => false
t.integer :user_id, :null => false
t.integer :version
t.integer :target_id
t.string :type
end
end
def self.down
drop_table :log_entries
end
end

9
db/migrate/026_admin.rb Normal file
View File

@@ -0,0 +1,9 @@
class Admin < ActiveRecord::Migration
def self.up
add_column :users, :admin, :boolean, :null => false, :default => false
end
def self.down
remove_column :users, :admin
end
end

View File

@@ -0,0 +1,11 @@
class AddCourseCode < ActiveRecord::Migration
def self.up
add_column :courses, :code, :string, :null => false, :default => "CK000"
add_column :courses, :period, :integer, :null => false, :default => 1
end
def self.down
remove_column :courses, :code
remove_column :courses, :period
end
end

View File

@@ -0,0 +1,35 @@
class CleanupDb < ActiveRecord::Migration
def self.up
change_column :attachments, :file_name, :string, :null => false
change_column :courses, :description, :text, :null => true
change_column :users, :login, :string, :null => false
change_column :users, :hashed_password, :string, :null => false
change_column :users, :email, :string, :null => false
change_column :users, :salt, :string, :null => false
change_column :users, :pref_color, :integer, :null => false
change_column :wiki_pages, :course_id, :integer, :null => false
change_column :wiki_pages, :user_id, :integer, :null => false
change_column :wiki_pages, :description, :string, :null => false
change_column :wiki_pages, :title, :string, :null => false
change_column :wiki_pages, :position, :integer, :null => true
drop_table :forum_forums
drop_table :forum_logged_exceptions
drop_table :forum_moderatorships
drop_table :forum_monitorships
drop_table :forum_open_id_authentication_associations
drop_table :forum_open_id_authentication_nonces
drop_table :forum_open_id_authentication_settings
drop_table :forum_posts
drop_table :forum_schema_info
drop_table :forum_sessions
drop_table :forum_topics
drop_table :forum_users
end
def self.down
end
end