First, you could add a task like this to deploy.rb:

   task :create_shared_db_directory do
     run "mkdir #{shared_path}/db"
   end
   after "deploy:setup", :create_shared_db_directory

Then you run it:

   cap create_shared_db_directory

Then tweak your database.yml so the production part looks like this:

   production:
     adapter: sqlite3
     database: <shared_path>/db/production.db

(Be sure to replace <shared_path>, above, with the full path to your  
"shared" directory in production, something like /u/apps/myapp/shared,  
depending on the value of your :deploy_to variable.)

Then, copy your production database to that shared path, and redeploy.  
Subsequent deploys shouldn't need any hand-holding--they'll all  
automatically look in the shared path for the db, and the shared path  
doesn't change across deployments.

- Jamis

P.S. Note that if you ever add another server, using a sqlite database  
will bite you pretty badly, because each server will be looking at its  
own copy of the database. It's probably best to just bite the bullet  
and learn how to use mysql with Rails, but a mysql+rails tutorial is  
beyond the scope of this mailing list.

On Jun 27, 2008, at 10:46 PM, BackVerse wrote:

>
> Hello!
>
> Well the thing is I really don't know how to begin doing that haha.
>
> Any help would be appreciated in doing this or I could just switch
> over :)
>
> Thanks,
> David Pham
>
> On Jun 27, 11:23 pm, "Anthony Ettinger" <[EMAIL PROTECTED]> wrote:
>> it should...but is it worth the effort swtiching dbs when all you  
>> need
>> to do is setup a persistent "shared" folder for your sqllite db?
>>
>>
>>
>> On Fri, Jun 27, 2008 at 9:19 PM, BackVerse  
>> <[EMAIL PROTECTED]> wrote:
>>
>>> I think the main thing is I need for cap deploy to carry over my
>>> previous database's data, and with sqlite it's not doing that. Will
>>> switching to postgre fix that?
>>
>>> Thanks,
>>> David Pham
>>
>>> On Jun 27, 11:12 pm, "Anthony Ettinger" <[EMAIL PROTECTED]> wrote:
>>>> postgres is a fine DB for the more experienced db programmer.
>>>> mysql works great too.
>>
>>>> (I've only tried RoR with mysql).
>>
>>>> If you need transaction support and more advanced db features, go  
>>>> with postgres.
>>
>>>> On Fri, Jun 27, 2008 at 9:08 PM, BackVerse  
>>>> <[EMAIL PROTECTED]> wrote:
>>
>>>>> Hello!
>>
>>>>> Thanks for the replies!
>>
>>>>> What kind of databases could I use to avoid have to put them  
>>>>> under the
>>>>> shared directory?
>>
>>>>> Is Postgre good?
>>
>>>>> Thanks,
>>>>> David Pham
>>
>>>>> On Jun 27, 10:43 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
>>>>>> If you're using sqlite databases in production (not something I'd
>>>>>> recommend, actually), then you need to make sure they get put  
>>>>>> under
>>>>>> the shared directory, rather than in your release directory.  
>>>>>> That's
>>>>>> something you'll need to configure in your app, or make happen  
>>>>>> in some
>>>>>> before/after hooks of your own.
>>
>>>>>> - Jamis
>>
>>>>>> On Jun 27, 2008, at 9:14 PM, Anthony Ettinger wrote:
>>
>>>>>>> On Fri, Jun 27, 2008 at 8:08 PM, BackVerse  
>>>>>>> <[EMAIL PROTECTED]>
>>>>>>> wrote:
>>
>>>>>>>> Hello!
>>
>>>>>>>> I just started using Capistrano and on my VPS I ran the  
>>>>>>>> following:
>>
>>>>>>>> cap deploy:setup
>>>>>>>> cap deploy:cold
>>
>>>>>>>> And that setup my application and ran the migrations, so it  
>>>>>>>> ran fine.
>>
>>>>>>>> However, now, when I run this command:
>>
>>>>>>>> cap deploy
>>
>>>>>>>> The databases are not being carried over along with their  
>>>>>>>> populated
>>>>>>>> data. All I see in the current release db folder is an empty
>>>>>>>> production.sqlite3 file and no schema.rb.
>>
>>>>>>>> So I manually have to run rake db:migrate  
>>>>>>>> RAILS_ENV=production, and
>>>>>>>> even that is not what I want since it builds the database  
>>>>>>>> anew with
>>>>>>>> no
>>>>>>>> data (I need the previous release's data)
>>
>>>>>>>> Is this normal, or do I need to do something extra to carry  
>>>>>>>> over the
>>>>>>>> database and its data from previous releases?
>>
>>>>>>> If it is a new release (you said you ran setup and cold  
>>>>>>> functions)...
>>>>>>> Is your DB empty?
>>>>>>> Are you expecting default data?
>>
>>>>>>> Try adding some things from the application interface (ie:
>>>>>>> example.com/admin) and then re-deploy...your data should  
>>>>>>> persist.
>>
>>>>>>> --
>>>>>>> Anthony Ettinger
>>>>>>> 408-656-2473
>>>>>>> http://anthony.ettinger.name
>>
>>>> --
>>>> Anthony Ettinger
>>>> 408-656-2473http://anthony.ettinger.name
>>
>> --
>> Anthony Ettinger
>> 408-656-2473http://anthony.ettinger.name
> >


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to