Added a rake task ('setup_tracks') which copies all the *.tmpl files and to a new file/directory name minus the .tmpl extension. Note that you do need to copy database.yml.tmpl -> database.yml first and edit it appropriately, or rake can't run any tasks!

Updated the documentation appropriately.


git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@136 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-08-10 20:01:48 +00:00
parent 66946fd14e
commit 0a7a50c7c3
3 changed files with 53 additions and 10 deletions

View file

@ -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!
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!

View file

@ -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

View file

@ -32,16 +32,19 @@ In the following, I'm assuming that you're using MySQL and the built-in WEBrick
<tt>mysql> GRANT ALL PRIVILEGES ON tracks.* TO yourmysqluser@localhost IDENTIFIED BY 'password-goes-here' WITH GRANT OPTION;</tt>
* 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 <tt>tracks/config/database.yml.tmpl</tt> and <tt>tracks/config/settings.yml.tmpl</tt> to the same file names without the <tt>*.tmpl</tt> extension (i.e. the extension should just be <tt>.yml</tt>).
* Copy the <tt>log.tmpl</tt> directory to <tt>log</tt>, and <tt>tmp.tmpl</tt> to <tt>tmp</tt>.
* Open the <tt>tracks/config/database.yml</tt> 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'. <b>NB</b>: 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 <tt>tracks/config/settings.yml</tt> 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. <b>NB:</b> 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 <tt>config/database.yml.tmpl</tt> to <tt>config/database.yml</tt>.
* Open the <tt>tracks/config/database.yml</tt> 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'. <b>NB</b>: 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. <b>NB:</b> 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:
<tt>cd /PATHTO/TRACKS</tt>
<tt>rake setup_tracks</tt>
* 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:
<tt>cd /PATHTO/TRACKS</tt>
<tt>rake migrate</tt>
* Check over the file <tt>config/settings.yml</tt>, 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 <tt>tracks/db</tt>). You don't have to use the example data, but if you don't, you'll need to visit <tt>http://YOURURL/contexts</tt> 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 <tt>tracks/public/dispatch.*</tt> files, and also <tt>/script/server</tt>. The default (<tt>#!/usr/bin/ruby</tt>) is fine for Mac OS X Tiger, but if you've installed Ruby yourself in <tt>/usr/local/bin</tt>, you'll need to change it.
* Run the following command at your command line (<b>Important:</b> 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 <tt>--port</tt> 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.
* <b>Make sure that you check <tt>settings.yml.tmpl</tt> for new info</b>, and add any new fields to your <tt>settings.yml</tt> 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, <b>BACK UP YOUR DATABASE</b> (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:
<tt>cd /PATHTO/TRACKS</tt>
<tt>rake setup_tracks</tt>
* If you are using MySQL or Postgresql, you can use the new Rakefile rake migrate task to update your tables. At your command line:
<tt>cd /PATHTO/TRACKS</tt>
@ -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.
* <b>Make sure that you check <tt>settings.yml.tmpl</tt> for new info</b>, and add any new fields to your <tt>settings.yml</tt> 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:
<tt>cd /PATHTO/TRACKS</tt>
<tt>rake setup_tracks</tt>
* If you're using SQLite/SQLite3, you'll need to create a new database and import the new schema (<tt>db/tracks_1.031_sqlite.sql</tt>), 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 <tt>db/tracks_1.0.3_content.sql</tt> 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 <tt>tracks/public/dispatch.*</tt> files, and also <tt>/script/server</tt>. The default (<tt>#!/usr/bin/ruby</tt>) is fine for Mac OS X Tiger, but if you've installed Ruby yourself in <tt>/usr/local/bin</tt>, you'll need to change it.