Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
fixed more nastiness in installer. gave up on sqlite being useful.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cook committed Jan 30, 2009
1 parent 9f9b5a0 commit 8c0a310
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config/database.yml
config/database.yml.bak
log/
log/*
*.swp
Expand Down
20 changes: 1 addition & 19 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,6 @@
t.string "configurable_type"
end

create_table "media_player_playlist_items", :force => true do |t|
t.integer "media_player_id"
t.string "playlist_item_song_file_name"
t.string "playlist_item_song_content_type"
t.integer "playlist_item_song_file_size"
end

add_index "media_player_playlist_items", ["media_player_id"], :name => "index_media_player_playlist_items_on_media_player_id"

create_table "media_players", :force => true do |t|
t.string "name"
end

create_table "menu_entries", :force => true do |t|
t.string "name"
t.string "link"
Expand Down Expand Up @@ -194,6 +181,7 @@
t.string "name"
t.string "title"
t.string "full_title"
t.string "status"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
Expand All @@ -204,7 +192,6 @@
t.boolean "published", :default => true
t.boolean "linked", :default => true
t.boolean "show_sub_menu", :default => false
t.string "status"
t.datetime "publish_at"
t.datetime "expires_on"
end
Expand All @@ -227,11 +214,6 @@
t.string "display_type"
end

create_table "plugin_schema_info", :id => false, :force => true do |t|
t.string "plugin_name"
t.integer "version"
end

create_table "posts", :force => true do |t|
t.integer "user_id"
t.integer "topic_id"
Expand Down
17 changes: 11 additions & 6 deletions lib/ansuz/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def choose_theme(theme_directory = File.join(RAILS_ROOT, "public", "themes"))
theme = @themes.detect{|t| t == theme_choice}
if( theme )
@state = :theme_installed
return SiteSetting.find_or_create_by_name(:default).update_attribute(:user_theme_name, theme)
begin
return SiteSetting.find_or_create_by_name(:default).update_attribute(:user_theme_name, theme)
rescue
STDERR.puts "Badness happened trying to set the default theme. SQLite does this a lot."
end
else
@state = :invalid_theme
@stdout.puts "[ansuz] invalid theme."
Expand Down Expand Up @@ -62,7 +66,7 @@ def create_db_config(database_yaml_path = File.join(RAILS_ROOT, "config", "datab
config["socket"] = get_user_response_for("[ansuz] Socket (/var/run/mysqld/mysqld.sock): ", "/var/run/mysqld/mysqld.sock")
config["database"] = get_user_response_for("[ansuz] Database Name Prefix (ansuz):", "ansuz")
else
config["database"] = get_user_response_for("[ansuz] Database Location (db/development.sqlite):", "db")
config["database"] = get_user_response_for("[ansuz] Database Location (db/development.sqlite):", "db/")
end

create_config_for_environment(["production","development","test"], config)
Expand All @@ -88,16 +92,17 @@ def install
create_database
end

@stdout.puts "[ansuz] Migrating tables .."
@stdout.puts "[ansuz] Migrating plugins .."
Kernel.silence_stream(@stdout) do
migrate_database
migrate_plugins
end

@stdout.puts "[ansuz] Migrating plugins .."
@stdout.puts "[ansuz] Migrating tables .."
Kernel.silence_stream(@stdout) do
migrate_plugins
migrate_database
end


# Create public/uploads directory for FCKeditor
create_fckeditor_uploads_dir

Expand Down
12 changes: 7 additions & 5 deletions spec/ansuz_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@
@installer.state.should == :user_doesnt_want_database_yaml
end

# You may be tempted to use sqlite for tests, but then you'd be in a world of pain. SQLite - is - the - devil
it "should prompt the user if he/she wants a database.yml created for them" do
@stdin.write "y\n"
@installer.create_db_config "pooptown"
@stdin.write "sqlite"
#@stdin.write "localhost"
#@stdin.write "root"
#@stdin.write ""
#@stdin.write "database"
@stdin.write "mysql\n"
@stdin.write "localhost"
@stdin.write "root"
@stdin.write ""
@stdin.write "\n"
@installer.state.should == :database_yaml_created_successfully
end

it "should run all the necessary rake tasks to get ansuz running" do
@stdin.write "y\n"
@installer.install
@installer.state.should == :installation_complete
File.exists?( File.join(RAILS_ROOT, "db", "schema.rb" )).should == true
Expand Down

0 comments on commit 8c0a310

Please sign in to comment.