Topic: Create Databases Needed by Kete
Topic type:
The steps necessary for creating databases supporting an installation of Kete.
Originally written by Walter McGinnis, Kete Project Lead for Katipo Communications, Ltd.
Part of the Installation Guide
MySQL instructions
Important Note: This step assumes that you are logged in as the user who will be running your Kete. For demos and development this is likely your normal account, for production this is the "kete" account if you have followed the conventions laid forth in the last step. You'll also need your MySQL root user's password to do this step.
Set up databases
We need to set up our databases for use with our new application. This is pretty simple, but does require some simple editing of a file and running some MySQL stuff. Here goes:
$ cd ~/apps/your_app/
$ cp config/database.example config/database.yml
Open config/database.yml in your text editor. Edit username and password settings to suit. You'll also want to change occurances of "kete_" to "your_app_", for example "kete_development" becomes "your_app_development".
After saving config/database.yml, you want to open a mysql session and create your databases and grant rights on them to whatever you chose for username in the file:
$ mysql -u root -p mysql # enter the mysql root password
...
mysql> create database your_app_production;
mysql> grant all on your_app_production.* to 'the_username_you_chose'@'localhost' identified by 'the_password_you_chose';
mysql> create database your_app_development;
mysql> grant all on your_app_development.* to 'the_username_you_chose'@'localhost';
mysql> create database your_app_test;
mysql> grant all on your_app_test.* to 'the_username_you_chose'@'localhost';
mysql> quit;
PostgreSQL instructions
Create Postgres user
This will need to be done as your database super-user, or a user empowered to create roles.
$ createuser kete
Should this user be a super-user? - NO
Should this user be allowed to create databases? - YES
Should this user be allowed to create more users? - NO
Refer to the PostgreSQL manual for further information if you need to configure a password or remote access; otherwise, if you are using a local database and unix authentication, no further setup is necessary.
The database will actually be created later by the deployment stage.
Configure database
Follow the instructions above for MySQL to get a new config/database.yml, and edit accordingly. Set the "adapter" to "postgresql" for each environment.
Next step:
Configure Backgroundrb
Discuss This Topic
There are 5 comments in this discussion.
Read and join this discussion
Hi Sam,
The db:bootstrap task is actually drops the db, creates a new blank version of it, then loads in the schema via a db:migrate, then loads default data.
So, it's not MySQL queries per se. It's actually that PG thinks that someone is connected to the database and therefore refuses to drop it.
In lib/tasks/bootstrap.rake try replacing this:
task :bootstrap => ['db:drop', 'db:create', 'db:bootstrap:load']
with this:
task :bootstrap => ['db:rewind', 'db:bootstrap:load']
and see if that works. Please report back here.
Cheers,
Walter
Ah, that "Engine=InnoDb" code is in a plugin which is why I wasn't familiar with it. I'll look into it tomorrow and let you know when there is a fix.
Thank you for your contribution of the PostgreSQL segment, by the way.
Cheers,
Walter
Alright, tracked it down to the acts_as_configurable plugin. I'll see if we can get them this to be db agnostic, but in the meantime you can try this:
In vendor/plugins/acts_as_configurable/lib/configurable_setting.rb, replace line 10 with this:
self.connection.create_table :configurable_settings do |t|
Let me know how that goes.
Cheers,
Walter
Tags: Postgresql, bootstrap
Here's a more permanent patch. Works with MySQL, if you could test it with PG, I would appreciate it. If it works with PG, I'll commit it to trunk:
table_options = String.new
self.connection.create_table :configurable_settings, :options => table_options do |t|
This is still in vendor/plugins/acts_as_configurable/lib/configuration_setting.rb, replace line 10.
I'm having a hard time tracking down the maintainer of the acts_as_configurable, so if this works, we'll commit locally as a modification of the plugin as it comes with Kete.
Cheers,
Walter
Tags: Postgresql, bootstrap, acts_as_configurable
samv
said bootstrap tries to apply MySQL queries
It seems that Kete is not picking up my database configuration at a late stage in the process; any ideas?
Excerpt from config/database.yml:
I can connect to this database and bootstrap; however it fails at the "CreateConfigurableSettings" stage;
Here is the trace: