# Deployment tips

**URL:** <https://www.ruby-forum.com/t/deployment-tips/149799>\
**Category:** Radiant CMS\
**Created:** [September 29, 2008, 11:41pm UTC](https://www.ruby-forum.com/t/deployment-tips/149799 "2008-09-29T23:41:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 29, 2008, 11:41pm UTC](https://www.ruby-forum.com/t/deployment-tips/149799/1 "2008-09-29T23:41:50Z")

</div>

I have built a radiant-based site and will soon be ready to deploy it.

I’m looking for advice on best practices. I was not able to find much  
about this in the documentation.

Most of the issue is the database. I want to be able update content in  
a copy of the site running on my development machine. Then, when I’m  
satisfied everything looks right, dump the database and import it into  
the production database running on the server.

Some content is stored in files. For example, the Page Attachments  
extension stores uploaded images in files (at least by default). I need  
to be able to update these files remotely.

Are there existing rake tasks for this sort of thing?

Thanks,  
Errol

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 30, 2008, 12:37am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/2 "2008-09-30T00:37:23Z")

</div>

If you are using mysql, I have written a custom extension that does a  
lot of what you want. It would need to be tailored a little for your  
environment, but I could email you a copy of it if you are interested.

Jamey C.

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 30, 2008, 12:38am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/3 "2008-09-30T00:38:46Z")

</div>

Jamey,

Yes – I’d love to see it.

Thanks,  
Errol

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 30, 2008, 3:38am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/4 "2008-09-30T03:38:44Z")

</div>

Jamey C. wrote:

> If you are using mysql, I have written a custom extension that does a  
> lot of what you want. It would need to be tailored a little for your  
> environment, but I could email you a copy of it if you are interested.

Of course, Jamey added a bit about this extension to Summer Reboot:  
[http://wiki.radiantcms.org/Migrating\_from\_SQLite\_to\_MySQL](http://wiki.radiantcms.org/Migrating_from_SQLite_to_MySQL)

Based on this experience, I hope that you can add a bit to Summer Reboot  
about deployment issues.  
Cheers,  
Mohit.  
9/30/2008 | 9:36 AM.

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 30, 2008, 3:47am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/5 "2008-09-30T03:47:35Z")

</div>

Ooops!! That’s what I get for answering e-mails just after waking up!  
That was actually Christopher D.; sorry guys!

Errol, you can take a look at the link below to see if that extension  
helps you any.

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 30, 2008, 4:29am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/6 "2008-09-30T04:29:56Z")

</div>

Mohit: Thanks for the link. I’ll take a look at that. Once I get this  
site ‘live’ I’ll be happy to document the experience.

Jamey: I’m still interested in seeing what you have done as well.

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 30, 2008, 5:45am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/7 "2008-09-30T05:45:44Z")

</div>

Hey Errol?!

On Mon, Sep 29, 2008 at 11:41 PM, Errol S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have built a radiant-based site and will soon be ready to deploy it.

“thin” and “nginx”. Take a look at the file system (should be  
something like XFS, JFS, Ext3 or ReiserFS). Nginx can do all that  
stuff yslow is complaining about (etags,… stuff). Do not use  
anything else than a B\*Tree-Filesystem…

There are tons of so called “Rails hosters” out there. DO NOT listen  
to them - mostly scam. What you need are those old-school hosters.  
Nobody cares about your rails installation, but when it comes to DNS,  
load balancing, storage (SAN without a real filesystem means nothing)  
and so on, you gonna need really experienced hosters.

Check out Level3 or something like that.

Andreas

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [October 1, 2008, 9:25pm UTC](https://www.ruby-forum.com/t/deployment-tips/149799/8 "2008-10-01T21:25:41Z")

</div>

On Mon, Sep 29, 2008 at 2:41 PM, Errol S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have built a radiant-based site and will soon be ready to deploy it.
> 
> I’m looking for advice on best practices. I was not able to find much  
> about this in the documentation.
> 
> Most of the issue is the database. I want to be able update content in  
> a copy of the site running on my development machine. Then, when I’m  
> satisfied everything looks right, dump the database and import it into  
> the production database running on the server.

Here’s the code from the model of my little publisher extension. It’s  
not quite ready for releasing yet, but it should give you an idea.  
This assumes your dev database is on the same host as the production  
database. And that you’re using postgres. 😃

Note: I have some tables (the event ones) that you won’t have, so you  
can remove those.

# Puts data from the development database into the production one

# (by deleting the production tables and recreating them and filling

# them with production data.

# Note: Obviously won’t work with enforced database foreign keys,

# so don’t make them.

# TODO: Also copy over user-provided photos from the dev env to the

production one  
class Publisher  
TABLES = %w( events event\_options users page\_parts pages layouts  
snippets )  
def self.publish!  
table\_string = TABLES.map { |t| "-t #{t} " }  
data = `pg_dump #{current_dev} -a #{table_string}`  
pg = IO::popen(“psql #{current\_prod}”, “w+”)

```
pg << "begin;"
  TABLES.each do |table|
    pg << "delete from #{table};"
  end
  pg << data
pg << "commit;"

```

end

private

def self.current\_dev  
config = Rails::Configuration.new  
config.database\_configuration[“development”][“database”]  
end

def self.current\_prod  
config = Rails::Configuration.new  
config.database\_configuration[“production”][“database”]  
end

end

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [September 30, 2008, 3:42am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/9 "2008-09-30T03:42:52Z")

</div>

Nope. That wasn’t me.

Jamey

---

<div class="post-metadata">

**Author:** ![errolsiegel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@errolsiegel](https://www.ruby-forum.com/u/errolsiegel)\
**Post date:** [October 3, 2008, 2:42am UTC](https://www.ruby-forum.com/t/deployment-tips/149799/10 "2008-10-03T02:42:52Z")

</div>

If possible, I want to NOT assume that I am using a particular database  
and that the development and production databases are on the same  
machine.

I have started playing with the import\_export extension  
([http://github.com/radiant/radiant-import-export-extension/tree/master](http://github.com/radiant/radiant-import-export-extension/tree/master))  
to see if it could help form the basis of my deployment strategy.

I have run into a problem, however, and I wonder if anybody else has  
tried this. It appears to not work well with the styles\_n\_scripts  
plugin.

Here are the steps I used to try this on my dev machine:

1. mysqldump -u root mysite\_production \> mysite.sql
2. rake production db:export TEMPLATE=db/export.yml
3. rake production db:drop
4. mysqladmin -u root create mysite\_production (db:create fails for  
reasons documented elsewhere on this forum)
5. rake production db:import TEMPLATE=db/export.yml

The result is that the site is unable to use the stylesheet I stored  
using the styles\_n\_scripts plugin.

It is interesting to note that the tables created by the  
styles\_n\_scripts plugin appear to be there, and my stylesheet appears to  
be in the database – with one missing attribute.

I used mysqldump to back up the newly imported version of the database.  
Diffing the original mysqldump (working) and new mysqldump (non-working)  
output reveals this:

INSERT INTO `text_assets` VALUES  
(1,‘Stylesheet’,‘stylesheet.css’,‘…snip…’,‘2008-07-10  
21:23:37’,‘2008-07-30 02:18:06’,1,1,87,NULL);

INSERT INTO `text_assets` VALUES  
(1,NULL,‘stylesheet.css’,‘…snip…’,‘2008-07-10 21:23:37’,‘2008-10-02  
21:00:10’,1,1,87,NULL);

Notice the NULL second field in the imported, non-working database.  
This second field is ‘class\_name.’

The problem appears (to me at least) to be with the import, not export.  
Notice that the missing field does indeed appear in the export.yml file:

TextAssets:  
“1”:  
class\_name: Stylesheet  
updated\_at: 2008-07-30 02:18:06 Z  
updated\_by\_id: 1  
filter\_id:  
lock\_version: 87  
id: 1  
created\_by\_id: 1  
filename: stylesheet.css  
content: |-  
…snip…  
created\_at: 2008-07-10 21:23:37 Z

So, any ideas?
