How to handle sample data?

We have a lot of sample data that is currently integrated into our CMS, so every new site starts with the same pages, text and images. This feels a bit messy to me, and I’m wondering if there’s a good way to segment the sample data from the rest of the app, and most importantly, a simple way to remove everything when it is time for the client to start entering their data.

I guess my ideal would be to have ‘packages’ of sample data that can be installed and removed via a single script. Are there any tools available to do anything like this?

Why can’t you just install the CMS with sample data and have a one-shot clear all data button and truncate tables???

I usually just have a sql file or sh script which inserts data, then another for emptying the tables.

You don’t really need to delete them, why not just have an if statement to show the tutorial if there is no user data to show on that page. If you used embedded video or image tutorials it would be easy to load in from a master site, making updates very easy.

Sample data can be useful for users. Desginers, etc…

Should be a separate script they can run if needed. Would rather have it optional and turn it on if needed, rather then default it to on and force/allow everyone to truncate tables

I’ve been working with Rails a bit lately, and there is a file called seed.rb that clears out all tables and then loads them with the bare minimum data needed to start.

Applying the same concept to sample data, I think I will write a sample.php script that can be run to install a demo site, and then a seed.php file that can be run to reset the site to a barebones state, ready for the client’s data.

What do you mean? Rails provides a framework for you to plug in your own data? That script looks at your schema and generates random values within the allowable field tables? This is something you wrote or that comes with rails? I just like to keep it in a class, that way it can be ran not only “on demand” but also as a part of installers, etc…

It’s a convention within rails that allows you to write your own data using ActiveRecord. For instance:

users = User.create([
  {:username => "admin", :email => "", :password => "pass", :password_confirmation => "confirmation"},
  {:username => "test", :email => "", :password => "pass", :password_confirmation => "confirmation"}

Oh well I’d say thats a given. You must use your API, populate the tables as a “black box”. Otherwise you’re going to have a maintenance burden on your hands.

It’s not a given for us (yet). But we’re getting there :slight_smile: