diff --git a/tracks/README_FIRST.txt b/tracks/README_FIRST.txt index c0e0c8b7..291b2e22 100644 --- a/tracks/README_FIRST.txt +++ b/tracks/README_FIRST.txt @@ -10,8 +10,5 @@ Database schemas for MySQL, PostgreSQL and SQLite are available in tracks/db, al Before you do anything else, you need to copy certain files and rename the copy: tracks/config/database.yml.tmpl -> tracks/config/database.yml - tracks/config/settings.yml.tmpl -> tracks/config/settings.yml - tracks/log.tmpl -> tracks/log - tracks/tmp.tmpl -> tracks/tmp -You need to put your settings into database.yml and settings.yml. Just leave the .tmpl versions as they are. I'm sorry to impose this extra step, but it's important for the subversion repository not to have your super-seekrit MySQL database user name and password checked in to the repository for all to see! \ No newline at end of file +You need to put your settings into database.yml. Just leave the .tmpl versions as they are. I'm sorry to impose this extra step, but it's important for the subversion repository not to have your super-seekrit MySQL database user name and password checked in to the repository for all to see! \ No newline at end of file diff --git a/tracks/Rakefile b/tracks/Rakefile index a22de1bd..0fa2775d 100644 --- a/tracks/Rakefile +++ b/tracks/Rakefile @@ -1,6 +1,8 @@ require 'rake' require 'rake/testtask' require 'rake/rdoctask' +require 'fileutils' +include FileUtils::Verbose $VERBOSE = nil TEST_CHANGES_SINCE = Time.now - 600 @@ -200,3 +202,33 @@ desc "Migrate the database according to the migrate scripts in db/migrate (only task :migrate => :environment do ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/db/migrate/', ENV["VERSION"] ? ENV["VERSION"].to_i : nil) end + +desc "Initialises the installation, copy the *.tmpl files and directories to versions named without the .tmpl extension. It won't overwrite the files and directories if you've already copied them. You need to manually copy database.yml.tmpl -> database.yml and fill in the details before you run this task." +task :setup_tracks => :environment do + # Check the root directory for template files + FileList["*.tmpl"].each do |template_file| + f = File.basename(template_file) # with suffix + f_only = File.basename(template_file,".tmpl") # without suffix + if File.exists?(f_only) + puts f_only + " already exists" + else + cp_r(f, f_only) + puts f_only + " created" + end + end + # Check the config dir for template files + # We can't convert the database.yml.tmpl file, because database.yml needs + # to exist for rake to run tasks! + cd("config") do + FileList["settings.yml.tmpl"].each do |template_file| + f = File.basename(template_file) # with suffix + f_only = File.basename(template_file,".tmpl") # without suffix + if File.exists?(f_only) + puts f_only + " already exists" + else + cp(f, f_only) + puts f_only + " created" + end + end + end +end diff --git a/tracks/doc/README_FOR_APP b/tracks/doc/README_FOR_APP index 57474733..132e6fed 100644 --- a/tracks/doc/README_FOR_APP +++ b/tracks/doc/README_FOR_APP @@ -32,16 +32,19 @@ In the following, I'm assuming that you're using MySQL and the built-in WEBrick mysql> GRANT ALL PRIVILEGES ON tracks.* TO yourmysqluser@localhost IDENTIFIED BY 'password-goes-here' WITH GRANT OPTION; -* Make sure that you've followed the instructions in tracks/README_FIRST.txt, and copied and renamed all the files and directories ending in .tmpl to remove the .tmpl extension. -* Copy the files tracks/config/database.yml.tmpl and tracks/config/settings.yml.tmpl to the same file names without the *.tmpl extension (i.e. the extension should just be .yml). -* Copy the log.tmpl directory to log, and tmp.tmpl to tmp. -* Open the tracks/config/database.yml file, and enter your username and password details for the database you just set up. If you're running in production mode, you only really need to set up the entry under 'production'. NB: If you do set up the entry for 'test', make sure that you specify a different database, or when you run tests, they will overwrite your data. -* Open the tracks/config/settings.yml file, and enter your desired format for dates and your email address for the signup page, along with the other configuration settings. The comments in settings.yml should make it self explanatory. NB: It's very important that you don't use TABS in any of the .yml files. Just use spaces to indent. -* The file tracks/Rakefile contains various useful tasks, one of which is 'migrate': this will populate the database you've made with the correct table schemas. It also adds a table 'schema_info', which keeps track of which version you are using. This means that you can potentially also revert back to an earlier schema. Use it as follows at the command line: +* Copy the file config/database.yml.tmpl to config/database.yml. +* Open the tracks/config/database.yml file, and enter your username and password details for the database you just set up. If you're running in production mode, you only really need to set up the entry under 'production'. NB: If you do set up the entry for 'test', make sure that you specify a different database, or when you run tests, they will overwrite your data. NB: It's very important that you don't use TABS in any of the .yml files. Just use spaces to indent. +* The file tracks/Rakefile contains various useful tasks you can run. The first one you need to run copies all the other files and directories with *.tmpl extensions and removes the extension: + + cd /PATHTO/TRACKS + rake setup_tracks + +* The next task you need to run is 'migrate': this will populate the database you've made with the correct table schemas. It also adds a table 'schema_info', which keeps track of which version you are using. This means that you can potentially also revert back to an earlier schema. Use it as follows at the command line: cd /PATHTO/TRACKS rake migrate +* Check over the file config/settings.yml, and make sure that the settings are to your liking. * If you'd also like some example data to play with, you can import it from tracks_1.031_content.sql (in tracks/db). You don't have to use the example data, but if you don't, you'll need to visit http://YOURURL/contexts first to add a few contexts before you add any next actions. Note that no users are provided in the content file, so you'll need to visit the signup page (http://YOURURL/signup) to create some users. * Check that the path to Ruby is correct in the tracks/public/dispatch.* files, and also /script/server. The default (#!/usr/bin/ruby) is fine for Mac OS X Tiger, but if you've installed Ruby yourself in /usr/local/bin, you'll need to change it. * Run the following command at your command line (Important: If you already have an application running on WEBrick (Tracks or anything else), make sure that you stop the server, or run Tracks on a different port using the --port option): @@ -58,6 +61,11 @@ In the following, I'm assuming that you're using MySQL and the built-in WEBrick * For safety, rename your current Tracks directory to 'tracks-old' or something similar, and if you are able, create a new database for the new version. If you can't create a new database, delete the contents and tables in your old one MAKING SURE THAT YOU HAVE BACKED UP YOUR DATABASE FIRST. * Make sure that you check settings.yml.tmpl for new info, and add any new fields to your settings.yml file. Some new settings have been added in the past couple of versions, and not having the correct settings is a common cause of errors. * Before you do anything else, BACK UP YOUR DATABASE (tables and content). Then make a separate export of the contents only (assuming that you want to move your data to the new version.) +* The file tracks/Rakefile contains various useful tasks you can run. The first one you need to run copies all the files and directories with *.tmpl extensions and removes the extension. It ignores any files or directories that you've already converted, so it's safe to run it when you're upgrading: + + cd /PATHTO/TRACKS + rake setup_tracks + * If you are using MySQL or Postgresql, you can use the new Rakefile rake migrate task to update your tables. At your command line: cd /PATHTO/TRACKS @@ -71,6 +79,12 @@ In the following, I'm assuming that you're using MySQL and the built-in WEBrick ==== SQLite or SQLite3 * For safety, rename your current Tracks directory to 'tracks-old' or something similar, and if you are able, create a new database for the new version. If you can't create a new database, delete the contents and tables in your old one MAKING SURE THAT YOU HAVE BACKED UP YOUR DATABASE FIRST. +* Make sure that you check settings.yml.tmpl for new info, and add any new fields to your settings.yml file. Some new settings have been added in the past couple of versions, and not having the correct settings is a common cause of errors. +* The file tracks/Rakefile contains various useful tasks you can run. The task 'setup_tracks' copies all the files and directories with *.tmpl extensions and removes the extension. It ignores any files or directories that you've already converted, so it's safe to run it when you're upgrading: + + cd /PATHTO/TRACKS + rake setup_tracks + * If you're using SQLite/SQLite3, you'll need to create a new database and import the new schema (db/tracks_1.031_sqlite.sql), and then import your old contents. You need to check that the new fields have sensible contents. In particular, check that the 'user_id' field in the todos, contexts and projects tables have the value of '1' (i.e. they are owned by your admin user, who should have an id of 1). Use db/tracks_1.0.3_content.sql as a guide for the correct syntax. sure that you get a fresh copy, or you'll get errors. * Check that the path to Ruby is correct in the tracks/public/dispatch.* files, and also /script/server. The default (#!/usr/bin/ruby) is fine for Mac OS X Tiger, but if you've installed Ruby yourself in /usr/local/bin, you'll need to change it.