Removed superfluous 'tracks' directory at the root of the repository.

Testing commits to github.
This commit is contained in:
bsag 2008-05-20 21:28:26 +01:00
parent 6a42901514
commit 4cbf5a34d3
2269 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,41 @@
# Verision 1.0.3 database
class CreateTracksDb < ActiveRecord::Migration
def self.up
create_table :contexts do |t|
t.column :name, :string, :null => false
t.column :position, :integer, :null => false
t.column :hide, :boolean, :default => false
end
create_table :projects do |t|
t.column :name, :string, :null => false
t.column :position, :integer, :null => false
t.column :done, :boolean, :default => false
end
create_table :todos do |t|
t.column :context_id, :integer, :null => false
t.column :project_id, :integer
t.column :description, :string, :null => false
t.column :notes, :text
t.column :done, :boolean, :default => false, :null => false
t.column :created, :datetime
t.column :due, :date
t.column :completed, :datetime
end
create_table :users do |t|
t.column :login, :string, :limit => 80, :null => false
t.column :password, :string, :limit => 40, :null => false
t.column :word, :string
t.column :is_admin, :boolean, :default => false, :null => false
end
end
def self.down
drop_table :contexts
drop_table :projects
drop_table :todos
drop_table :users
end
end

View file

@ -0,0 +1,21 @@
class AddUserId < ActiveRecord::Migration
class Project < ActiveRecord::Base; end
class Context < ActiveRecord::Base; end
class Todo < ActiveRecord::Base; end
def self.up
add_column :contexts, :user_id, :integer, :default => 1
add_column :projects, :user_id, :integer, :default => 1
add_column :todos, :user_id, :integer, :default => 1
Context.find(:all).each { |context| context.user_id = 1 }
Project.find(:all).each { |project| project.user_id = 1 }
Todo.find(:all).each { |todo| todo.user_id = 1 }
end
def self.down
remove_column :contexts, :user_id
remove_column :projects, :user_id
remove_column :todos, :user_id
end
end

View file

@ -0,0 +1,12 @@
class CreatedAt < ActiveRecord::Migration
# Current bug in Rails that prevents rename_column working in SQLite
# if the column names use symbols instead of strings.
# <http://dev.rubyonrails.org/changeset/2731>
def self.up
rename_column :todos, 'created', 'created_at'
end
def self.down
rename_column :todos, 'created_at', 'created'
end
end

15
db/migrate/004_notes.rb Normal file
View file

@ -0,0 +1,15 @@
class Notes < ActiveRecord::Migration
def self.up
create_table :notes do |t|
t.column :user_id, :integer, :null => false
t.column :project_id, :integer, :null => false
t.column :body, :text
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
end
def self.down
drop_table :notes
end
end

View file

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

View file

@ -0,0 +1,17 @@
class AddPreferencesToUserTable < ActiveRecord::Migration
class User < ActiveRecord::Base; end
def self.up
add_column :users, :preferences, :text
@users = User.find(:all)
@users.each do |u|
u.preferences = { "date_format" => "%d/%m/%Y", "week_starts" => "1", "no_completed" => "5", "staleness_starts" => "7", "due_style" => "1", "admin_email" => "butshesagirl@rousette.org.uk"}
u.save
end
end
def self.down
remove_column :users, :preferences
end
end

View file

@ -0,0 +1,15 @@
class AddSessionsTable < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.column :session_id, :string
t.column :data, :text
t.column :updated_at, :datetime
end
add_index :sessions, :session_id
end
def self.down
drop_table :sessions
end
end

View file

@ -0,0 +1,16 @@
class AddSubclassAttrToTodos < ActiveRecord::Migration
class Todo < ActiveRecord::Base; end
class Immediate < Todo; end
def self.up
add_column :todos, :type, :string, :null => false, :default => "Immediate"
add_column :todos, :show_from, :date
Todo.find(:all).each { |todo| todo.type = "Immediate" }
end
def self.down
remove_column :todos, :type
remove_column :todos, :show_from
end
end

View file

@ -0,0 +1,15 @@
class AddUserPrefRefresh < ActiveRecord::Migration
class User < ActiveRecord::Base; serialize :preferences; end
def self.up
@users = User.find(:all)
@users.each do |user|
user.preferences.merge!({"refresh" => "0"})
user.save
end
end
def self.down
end
end

View file

@ -0,0 +1,11 @@
class AddFirstAndLastNameToUser < ActiveRecord::Migration
def self.up
add_column :users, :first_name, :string
add_column :users, :last_name, :string
end
def self.down
remove_column :users, :first_name
remove_column :users, :last_name
end
end

View file

@ -0,0 +1,22 @@
class PrefToShowHideSidebarItems < ActiveRecord::Migration
class User < ActiveRecord::Base; serialize :preferences; end
def self.up
@users = User.find(:all)
@users.each do |user|
user.preferences.merge!({"show_completed_projects_in_sidebar" => true})
user.preferences.merge!({"show_hidden_contexts_in_sidebar" => true})
user.save
end
end
def self.down
@users = User.find(:all)
@users.each do |user|
user.preferences.delete("show_completed_projects_in_sidebar")
user.preferences.delete("show_hidden_contexts_in_sidebar")
user.save
end
end
end

View file

@ -0,0 +1,23 @@
class AddPreferencesModel < ActiveRecord::Migration
class User < ActiveRecord::Base; serialize :preferences; end
def self.up
create_table :preferences do |t|
t.column :user_id, :integer, :null => false
t.column :date_format, :string, :limit => 40, :null => false, :default => '%d/%m/%Y'
t.column :week_starts, :integer, :null => false, :default => 0
t.column :show_number_completed, :integer, :null => false, :default => 5
t.column :staleness_starts, :integer, :null => false, :default => 7
t.column :show_completed_projects_in_sidebar, :boolean, :default => true, :null => false
t.column :show_hidden_contexts_in_sidebar, :boolean, :default => true, :null => false
t.column :due_style, :integer, :null => false, :default => 0
t.column :admin_email, :string, :limit => 255, :null => false, :default => 'butshesagirl@rousette.org.uk'
t.column :refresh, :integer, :null => false, :default => 0
end
end
def self.down
drop_table :preferences
end
end

View file

@ -0,0 +1,45 @@
class ConvertPreferences < ActiveRecord::Migration
class User < ActiveRecord::Base; has_one :preference; serialize :preferences; end
def self.up
@users = User.find(:all)
@users.each do |user|
user.create_preference
user.preference.date_format = user.preferences['date_format']
user.preference.week_starts = user.preferences['week_starts']
user.preference.show_number_completed = user.preferences['no_completed']
user.preference.staleness_starts = user.preferences['staleness_starts']
user.preference.show_completed_projects_in_sidebar = user.preferences['show_completed_projects_in_sidebar']
user.preference.show_hidden_contexts_in_sidebar = user.preferences['show_hidden_contexts_in_sidebar']
user.preference.due_style = user.preferences['due_style']
user.preference.admin_email = user.preferences['admin_email']
user.preference.refresh = user.preferences['refresh']
if user.preference.refresh.blank?
user.preference.refresh = 0
end
user.preference.save!
end
remove_column :users, :preferences
end
def self.down
add_column :users, :preferences, :text
@users = User.find(:all)
@users.each do |user|
user.preferences = { "date_format" => "#{user.preference.date_format}",
"week_starts" => "#{user.preference.week_starts}",
"no_completed" => "#{user.preference.show_number_completed}",
"staleness_starts" => "#{user.preference.staleness_starts}",
"show_completed_projects_in_sidebar" => "#{user.preference.show_completed_projects_in_sidebar}",
"show_hidden_contexts_in_sidebar" => "#{user.preference.show_hidden_contexts_in_sidebar}",
"due_style" => "#{user.preference.due_style}",
"admin_email" => "#{user.preference.admin_email}",
"refresh" => "#{user.preference.refresh}"
}
user.save
end
end
end

View file

@ -0,0 +1,24 @@
class ConvertProjectToStateMachine < ActiveRecord::Migration
class Project < ActiveRecord::Base; end
def self.up
add_column :projects, :state, :string, :limit => 20, :default => "active", :null => false
@projects = Project.find(:all)
@projects.each do |project|
project.state = project.done? ? 'completed' : 'active'
project.save
end
remove_column :projects, :done
end
def self.down
add_column :projects, :done, :integer, :limit => 4, :default => 0, :null => false
@projects = Project.find(:all)
@projects.each do |project|
project.done = project.state == 'completed'
project.save
end
remove_column :projects, :state
end
end

View file

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

View file

@ -0,0 +1,9 @@
class AddUserAuthType < ActiveRecord::Migration
def self.up
add_column :users, :auth_type, :string, :default => 'database', :null => false
end
def self.down
remove_column :users, :auth_type
end
end

View file

@ -0,0 +1,45 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
class AddOpenIdTables < ActiveRecord::Migration
def self.up
create_table "open_id_associations", :force => true do |t|
t.column "server_url", :binary
t.column "handle", :string
t.column "secret", :binary
t.column "issued", :integer
t.column "lifetime", :integer
t.column "assoc_type", :string
end
create_table "open_id_nonces", :force => true do |t|
t.column "nonce", :string
t.column "created", :integer
end
create_table "open_id_settings", :force => true do |t|
t.column "setting", :string
t.column "value", :binary
end
end
def self.down
drop_table "open_id_associations"
drop_table "open_id_nonces"
drop_table "open_id_settings"
end
end

View file

@ -0,0 +1,9 @@
class AddUserOpenIdUrl < ActiveRecord::Migration
def self.up
add_column :users, :open_id_url, :string
end
def self.down
remove_column :users, :open_id_url
end
end

View file

@ -0,0 +1,40 @@
class ConvertTodoToStateMachine < ActiveRecord::Migration
class Todo < ActiveRecord::Base; belongs_to :project; end
class Immediate < Todo; end
class Deferred < Todo; end
class Project < ActiveRecord::Base; end
def self.up
add_column :todos, :state, :string, :limit => 20, :default => "immediate", :null => false
@todos = Todo.find(:all)
@todos.each do |todo|
if todo.done?
todo.state = 'completed'
elsif todo.type == 'Deferred'
todo.state = 'deferred'
elsif !todo.project.nil? && todo.project.state == 'hidden'
todo.state = 'project_hidden'
else
todo.state = 'active'
end
todo.save
end
rename_column :todos, 'completed', 'completed_at' #bug in sqlite requires column names as strings
remove_column :todos, :done
remove_column :todos, :type
end
def self.down
add_column :todos, :done, :integer, :limit => 4, :default => 0, :null => false
add_column :todos, :type, :string, :default => "Immediate", :null => false
rename_column :todos, 'completed_at', 'completed' #bug in sqlite requires column names as strings
@todos = Todo.find(:all)
@todos.each do |todo|
todo.done = todo.state == 'completed'
todo.type = todo.type == 'deferred' ? 'Deferred' : 'Immediate'
todo.save
end
remove_column :todos, :state
end
end

View file

@ -0,0 +1,11 @@
class PrefToShowHiddenProjectsInSidebar < ActiveRecord::Migration
def self.up
add_column :preferences, :show_hidden_projects_in_sidebar, :boolean, :default => true, :null => false
end
def self.down
remove_column :preferences, :show_hidden_projects_in_sidebar
end
end

View file

@ -0,0 +1,11 @@
class AddTimeZonePreference < ActiveRecord::Migration
def self.up
add_column :preferences, :time_zone, :string, :limit => 255, :default => 'London', :null => false
end
def self.down
remove_column :preferences, :time_zone
end
end

View file

@ -0,0 +1,23 @@
class AddIndices < ActiveRecord::Migration
def self.up
add_index :todos, [:user_id, :state]
add_index :todos, [:user_id, :project_id]
add_index :todos, [:project_id]
add_index :todos, [:context_id]
add_index :todos, [:user_id, :context_id]
add_index :preferences, :user_id
add_index :projects, :user_id
add_index :contexts, :user_id
end
def self.down
remove_index :contexts, :user_id
remove_index :projects, :user_id
remove_index :preferences, :user_id
remove_index :todos, [:user_id, :context_id]
remove_index :todos, [:project_id]
remove_index :todos, [:context_id]
remove_index :todos, [:user_id, :project_id]
remove_index :todos, [:user_id, :state]
end
end

View file

@ -0,0 +1,9 @@
class IndexOnUserLogin < ActiveRecord::Migration
def self.up
add_index :users, :login
end
def self.down
remove_index :users, :login
end
end

View file

@ -0,0 +1,11 @@
class AddFindByNameIndices < ActiveRecord::Migration
def self.up
add_index :projects, [:user_id, :name]
add_index :contexts, [:user_id, :name]
end
def self.down
remove_index :projects, [:user_id, :name]
remove_index :contexts, [:user_id, :name]
end
end

View file

@ -0,0 +1,23 @@
class AddTagSupport < ActiveRecord::Migration
def self.up
create_table :taggings do |t|
t.column :taggable_id, :integer
t.column :tag_id, :integer
t.column :taggable_type, :string
t.column :user_id, :integer
end
create_table :tags do |t|
t.column :name, :string
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
add_index :tags, :name
add_index :taggings, [:tag_id, :taggable_id, :taggable_type]
end
def self.down
drop_table :taggings
drop_table :tags
end
end

View file

@ -0,0 +1,12 @@
class AddProjectTimestamps < ActiveRecord::Migration
def self.up
add_column :projects, :created_at, :timestamp
add_column :projects, :updated_at, :timestamp
end
def self.down
remove_column :projects, :created_at
remove_column :projects, :updated_at
end
end

View file

@ -0,0 +1,13 @@
class AddContextTimestamps < ActiveRecord::Migration
def self.up
add_column :contexts, :created_at, :timestamp
add_column :contexts, :updated_at, :timestamp
end
def self.down
remove_column :contexts, :created_at
remove_column :contexts, :updated_at
end
end

View file

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

View file

@ -0,0 +1,9 @@
class AddTitleDateFormatPreference < ActiveRecord::Migration
def self.up
add_column :preferences, :title_date_format, :string, :limit => 255, :default => '%A, %d %B %Y', :null => false
end
def self.down
remove_column :preferences, :title_date_format
end
end

View file

@ -0,0 +1,25 @@
class SetNilTimestamps < ActiveRecord::Migration
class Project < ActiveRecord::Base; end
class Context < ActiveRecord::Base; end
def self.up
Project.find_all_by_created_at(nil).each do |p|
Project.update( p.id, {:created_at => Time.now.utc} )
end
Project.find_all_by_updated_at(nil).each do |p|
Project.update( p.id, {:updated_at => Time.now.utc} )
end
Context.find_all_by_created_at(nil).each do |p|
Context.update( p.id, {:created_at => Time.now.utc} )
end
Context.find_all_by_updated_at(nil).each do |p|
Context.update( p.id, {:updated_at => Time.now.utc} )
end
end
def self.down
#nothing to do here...
end
end

View file

@ -0,0 +1,9 @@
class AddDefaultContextToProject < ActiveRecord::Migration
def self.up
add_column :projects, :default_context_id, :integer
end
def self.down
remove_column :projects, :default_context_id
end
end

View file

@ -0,0 +1,9 @@
class AddMobileTodosPerPagePreference < ActiveRecord::Migration
def self.up
add_column :preferences, :mobile_todos_per_page, :integer, :null => false, :default => 6
end
def self.down
remove_column :preferences, :mobile_todos_per_page
end
end

View file

@ -0,0 +1,13 @@
class AddRememberMeToUser < ActiveRecord::Migration
def self.up
rename_column :users, 'password', 'crypted_password' #bug in sqlite requires column names as strings
add_column :users, :remember_token, :string
add_column :users, :remember_token_expires_at, :datetime
end
def self.down
remove_column :users, :remember_token
remove_column :users, :remember_token_expires_at
rename_column :users, 'crypted_password', 'password' #bug in sqlite requires column names as strings
end
end

View file

@ -0,0 +1,9 @@
class RenameWordToToken < ActiveRecord::Migration
def self.up
rename_column :users, 'word', 'token' #bug in sqlite requires column names as strings
end
def self.down
rename_column :users, 'token', 'word' #bug in sqlite requires column names as strings
end
end

View file

@ -0,0 +1,29 @@
class UpdateOpenIdUrls < ActiveRecord::Migration
class User < ActiveRecord::Base
def normalize_open_id_url
return if open_id_url.nil?
self.open_id_url = self.class.normalize_open_id_url(open_id_url)
end
def self.normalize_open_id_url(raw_open_id_url)
normalized = raw_open_id_url
normalized = "http://#{raw_open_id_url}" unless raw_open_id_url =~ /\:\/\//
normalized.downcase.chomp('/')
end
end
def self.up
User.find(:all).each do |user|
original = user.open_id_url
user.normalize_open_id_url
say "#{original} -> #{user.open_id_url}"
user.save! unless user.open_id_url == original
end
end
def self.down
end
end

View file

@ -0,0 +1,17 @@
class AddProjectCompletedAtColumn < ActiveRecord::Migration
class Project < ActiveRecord::Base; end
def self.up
add_column :projects, :completed_at, :datetime
@projects = Project.find(:all)
@projects.select{ |project| project.state == 'completed'}.each do |project|
project.completed_at = project.updated_at
project.save
end
end
def self.down
remove_column :projects, :completed_at
end
end

View file

@ -0,0 +1,11 @@
class AddIndexToNotes < ActiveRecord::Migration
def self.up
add_index :notes, [:project_id]
add_index :notes, [:user_id]
end
def self.down
remove_index :notes, [:user_id]
remove_index :notes, [:project_id]
end
end

View file

@ -0,0 +1,22 @@
class ProjectsContextsRemoveNotNullFromPosition < ActiveRecord::Migration
def self.up
change_column :projects, :position, :integer, {:null => true, :default => nil}
change_column :contexts, :position, :integer, {:null => true, :default => nil}
end
def self.down
@projects = Project.find(:all)
@projects.each do |project|
project.position = 0 if !project.position?
project.save
end
change_column :projects, :position, :integer, {:null => false, :default => nil}
@contexts = Context.find(:all)
@contexts.each do |context|
context.position = 0 if !context.position?
context.save
end
change_column :contexts, :position, :integer, {:null => false, :default => nil}
end
end