mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-05 23:41:48 +01:00
Removed superfluous 'tracks' directory at the root of the repository.
Testing commits to github.
This commit is contained in:
parent
6a42901514
commit
4cbf5a34d3
2269 changed files with 0 additions and 0 deletions
41
db/migrate/001_create_tracks_db.rb
Normal file
41
db/migrate/001_create_tracks_db.rb
Normal 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
|
||||
21
db/migrate/002_add_user_id.rb
Normal file
21
db/migrate/002_add_user_id.rb
Normal 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
|
||||
12
db/migrate/003_created_at.rb
Normal file
12
db/migrate/003_created_at.rb
Normal 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
15
db/migrate/004_notes.rb
Normal 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
|
||||
9
db/migrate/005_add_project_description.rb
Normal file
9
db/migrate/005_add_project_description.rb
Normal 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
|
||||
17
db/migrate/006_add_preferences_to_user_table.rb
Normal file
17
db/migrate/006_add_preferences_to_user_table.rb
Normal 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
|
||||
15
db/migrate/007_add_sessions_table.rb
Normal file
15
db/migrate/007_add_sessions_table.rb
Normal 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
|
||||
16
db/migrate/008_add_subclass_attr_to_todos.rb
Normal file
16
db/migrate/008_add_subclass_attr_to_todos.rb
Normal 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
|
||||
15
db/migrate/009_add_user_pref_refresh.rb
Normal file
15
db/migrate/009_add_user_pref_refresh.rb
Normal 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
|
||||
11
db/migrate/010_add_first_and_last_name_to_user.rb
Normal file
11
db/migrate/010_add_first_and_last_name_to_user.rb
Normal 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
|
||||
22
db/migrate/011_pref_to_show_hide_sidebar_items.rb
Normal file
22
db/migrate/011_pref_to_show_hide_sidebar_items.rb
Normal 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
|
||||
23
db/migrate/012_add_preferences_model.rb
Normal file
23
db/migrate/012_add_preferences_model.rb
Normal 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
|
||||
45
db/migrate/013_convert_preferences.rb
Normal file
45
db/migrate/013_convert_preferences.rb
Normal 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
|
||||
24
db/migrate/014_convert_project_to_state_machine.rb
Normal file
24
db/migrate/014_convert_project_to_state_machine.rb
Normal 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
|
||||
|
|
@ -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
|
||||
9
db/migrate/016_add_user_auth_type.rb
Normal file
9
db/migrate/016_add_user_auth_type.rb
Normal 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
|
||||
45
db/migrate/017_add_open_id_tables.rb
Normal file
45
db/migrate/017_add_open_id_tables.rb
Normal 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
|
||||
9
db/migrate/018_add_user_open_id_url.rb
Normal file
9
db/migrate/018_add_user_open_id_url.rb
Normal 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
|
||||
40
db/migrate/019_convert_todo_to_state_machine.rb
Normal file
40
db/migrate/019_convert_todo_to_state_machine.rb
Normal 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
|
||||
11
db/migrate/020_pref_to_show_hidden_projects_in_sidebar.rb
Normal file
11
db/migrate/020_pref_to_show_hidden_projects_in_sidebar.rb
Normal 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
|
||||
11
db/migrate/021_add_time_zone_preference.rb
Normal file
11
db/migrate/021_add_time_zone_preference.rb
Normal 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
|
||||
23
db/migrate/022_add_indices.rb
Normal file
23
db/migrate/022_add_indices.rb
Normal 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
|
||||
9
db/migrate/023_index_on_user_login.rb
Normal file
9
db/migrate/023_index_on_user_login.rb
Normal 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
|
||||
11
db/migrate/024_add_find_by_name_indices.rb
Normal file
11
db/migrate/024_add_find_by_name_indices.rb
Normal 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
|
||||
23
db/migrate/025_add_tag_support.rb
Normal file
23
db/migrate/025_add_tag_support.rb
Normal 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
|
||||
12
db/migrate/026_add_project_timestamps.rb
Normal file
12
db/migrate/026_add_project_timestamps.rb
Normal 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
|
||||
13
db/migrate/027_add_context_timestamps.rb
Normal file
13
db/migrate/027_add_context_timestamps.rb
Normal 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
|
||||
|
|
@ -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
|
||||
9
db/migrate/029_add_title_date_format_preference.rb
Normal file
9
db/migrate/029_add_title_date_format_preference.rb
Normal 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
|
||||
25
db/migrate/030_set_nil_timestamps.rb
Normal file
25
db/migrate/030_set_nil_timestamps.rb
Normal 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
|
||||
9
db/migrate/031_add_default_context_to_project.rb
Normal file
9
db/migrate/031_add_default_context_to_project.rb
Normal 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
|
||||
9
db/migrate/032_add_mobile_todos_per_page_preference.rb
Normal file
9
db/migrate/032_add_mobile_todos_per_page_preference.rb
Normal 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
|
||||
13
db/migrate/033_add_remember_me_to_user.rb
Normal file
13
db/migrate/033_add_remember_me_to_user.rb
Normal 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
|
||||
9
db/migrate/034_rename_word_to_token.rb
Normal file
9
db/migrate/034_rename_word_to_token.rb
Normal 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
|
||||
29
db/migrate/035_update_open_id_urls.rb
Normal file
29
db/migrate/035_update_open_id_urls.rb
Normal 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
|
||||
17
db/migrate/036_add_project_completed_at_column.rb
Normal file
17
db/migrate/036_add_project_completed_at_column.rb
Normal 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
|
||||
11
db/migrate/037_add_index_to_notes.rb
Normal file
11
db/migrate/037_add_index_to_notes.rb
Normal 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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue