Fix migrations and update schema
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
class Canonical< ActiveRecord::Migration
|
class Canonical< ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
add_column :wiki_pages, :canonical_title, :string
|
add_column :wiki_pages, :canonical_title, :string
|
||||||
WikiPage.find(:all).each do |wiki|
|
#WikiPage.find(:all).each do |wiki|
|
||||||
wiki.update_attribute(:canonical_title, wiki.title.pretty_url)
|
# wiki.update_attribute(:canonical_title, wiki.title.pretty_url)
|
||||||
end
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
|||||||
38
db/migrate/20150906010325_add_not_null.rb
Normal file
38
db/migrate/20150906010325_add_not_null.rb
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
class AddNotNull < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
change_column_null :courses, :period, false, "0000.0"
|
||||||
|
|
||||||
|
change_column_null :wiki_pages, :canonical_title, false, ""
|
||||||
|
change_column_null :wiki_pages, :position, false, 0
|
||||||
|
change_column_null :wiki_pages, :created_at, false, Time.now
|
||||||
|
change_column_null :wiki_pages, :updated_at, false, Time.now
|
||||||
|
|
||||||
|
change_column_null :wiki_page_versions, :wiki_page_id, false, WikiPage.first.id
|
||||||
|
change_column_null :wiki_page_versions, :version, false, 1
|
||||||
|
change_column_null :wiki_page_versions, :course_id, false, Course.first.id
|
||||||
|
change_column_null :wiki_page_versions, :user_id, false, User.first.id
|
||||||
|
change_column_null :wiki_page_versions, :description, false, ''
|
||||||
|
change_column_null :wiki_page_versions, :title, false, ''
|
||||||
|
change_column_null :wiki_page_versions, :content, false, ''
|
||||||
|
change_column_null :wiki_page_versions, :created_at, false, Time.now
|
||||||
|
change_column_null :wiki_page_versions, :updated_at, false, Time.now
|
||||||
|
change_column_null :wiki_page_versions, :position, false, 0
|
||||||
|
|
||||||
|
WikiPage.with_deleted.where(canonical_title: '').each do |wp|
|
||||||
|
wp.update_attribute(:canonical_title, wp.title.pretty_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_column_null :courses, :period, true
|
||||||
|
|
||||||
|
change_column_null :wiki_pages, :canonical_title, true
|
||||||
|
change_column_null :wiki_pages, :position, true
|
||||||
|
change_column_null :wiki_pages, :created_at, true
|
||||||
|
change_column_null :wiki_pages, :updated_at, true
|
||||||
|
|
||||||
|
change_column_null :wiki_page_versions, :created_at, true
|
||||||
|
change_column_null :wiki_page_versions, :updated_at, true
|
||||||
|
end
|
||||||
|
end
|
||||||
8
db/migrate/20150906014206_remove_unversioned_field.rb
Normal file
8
db/migrate/20150906014206_remove_unversioned_field.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class RemoveUnversionedField < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
remove_column :wiki_page_versions, :position
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
||||||
66
db/schema.rb
66
db/schema.rb
@@ -1,15 +1,17 @@
|
|||||||
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
# encoding: UTF-8
|
||||||
# please use the migrations feature of Active Record to incrementally modify your database, and
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
# then regenerate this schema definition.
|
# 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
|
# Note that this schema.rb definition is the authoritative source for your
|
||||||
# to create the application database on another system, you should be using db:schema:load, not running
|
# database schema. If you need to create the application database on another
|
||||||
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
# 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).
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20090908200528) do
|
ActiveRecord::Schema.define(:version => 20150906014206) do
|
||||||
|
|
||||||
create_table "attachments", :force => true do |t|
|
create_table "attachments", :force => true do |t|
|
||||||
t.string "file_name", :null => false
|
t.string "file_name", :null => false
|
||||||
@@ -28,9 +30,9 @@ ActiveRecord::Schema.define(:version => 20090908200528) do
|
|||||||
t.string "full_name", :null => false
|
t.string "full_name", :null => false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.string "code", :default => "CK000", :null => false
|
t.string "code", :default => "CK000", :null => false
|
||||||
|
t.integer "grade", :default => 1, :null => false
|
||||||
t.datetime "deleted_at"
|
t.datetime "deleted_at"
|
||||||
t.integer "grade", :default => 1
|
t.string "period", :null => false
|
||||||
t.string "period"
|
|
||||||
t.boolean "hidden", :default => false, :null => false
|
t.boolean "hidden", :default => false, :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -45,22 +47,23 @@ ActiveRecord::Schema.define(:version => 20090908200528) do
|
|||||||
t.integer "event_id"
|
t.integer "event_id"
|
||||||
t.integer "version"
|
t.integer "version"
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
t.date "date"
|
||||||
|
t.datetime "time"
|
||||||
t.integer "created_by"
|
t.integer "created_by"
|
||||||
t.integer "course_id", :default => 0
|
t.integer "course_id", :default => 0
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.datetime "deleted_at"
|
t.datetime "deleted_at"
|
||||||
t.datetime "time", :default => '2008-03-05 04:25:27'
|
|
||||||
t.datetime "updated_at"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "events", :force => true do |t|
|
create_table "events", :force => true do |t|
|
||||||
t.string "title", :null => false
|
t.string "title", :null => false
|
||||||
t.integer "created_by", :null => false
|
t.date "date"
|
||||||
t.integer "course_id", :default => 0, :null => false
|
t.datetime "time", :null => false
|
||||||
|
t.integer "created_by", :null => false
|
||||||
|
t.integer "course_id", :default => 0, :null => false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.datetime "deleted_at"
|
t.datetime "deleted_at"
|
||||||
t.datetime "time", :default => '2008-03-05 04:25:27', :null => false
|
t.integer "version", :default => 1, :null => false
|
||||||
t.integer "version", :default => 1, :null => false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "log_entries", :force => true do |t|
|
create_table "log_entries", :force => true do |t|
|
||||||
@@ -97,6 +100,10 @@ ActiveRecord::Schema.define(:version => 20090908200528) do
|
|||||||
t.integer "version", :default => 1, :null => false
|
t.integer "version", :default => 1, :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "schema_info", :id => false, :force => true do |t|
|
||||||
|
t.integer "version"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "sessions", :force => true do |t|
|
create_table "sessions", :force => true do |t|
|
||||||
t.string "session_id", :null => false
|
t.string "session_id", :null => false
|
||||||
t.text "data"
|
t.text "data"
|
||||||
@@ -126,16 +133,15 @@ ActiveRecord::Schema.define(:version => 20090908200528) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "wiki_page_versions", :force => true do |t|
|
create_table "wiki_page_versions", :force => true do |t|
|
||||||
t.integer "wiki_page_id"
|
t.integer "wiki_page_id", :null => false
|
||||||
t.integer "version"
|
t.integer "version", :null => false
|
||||||
t.integer "course_id"
|
t.integer "course_id", :null => false
|
||||||
t.integer "user_id"
|
t.integer "user_id", :null => false
|
||||||
t.string "description"
|
t.string "description", :null => false
|
||||||
t.string "title"
|
t.string "title", :null => false
|
||||||
t.text "content"
|
t.text "content", :null => false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "position"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "wiki_pages", :force => true do |t|
|
create_table "wiki_pages", :force => true do |t|
|
||||||
@@ -145,11 +151,11 @@ ActiveRecord::Schema.define(:version => 20090908200528) do
|
|||||||
t.string "description", :null => false
|
t.string "description", :null => false
|
||||||
t.string "title", :null => false
|
t.string "title", :null => false
|
||||||
t.text "content", :null => false
|
t.text "content", :null => false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "position"
|
t.integer "position", :null => false
|
||||||
t.datetime "deleted_at"
|
t.datetime "deleted_at"
|
||||||
t.string "canonical_title"
|
t.string "canonical_title", :null => false
|
||||||
t.boolean "front_page", :default => true, :null => false
|
t.boolean "front_page", :default => true, :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user