Clean up your clean installation

When you install ExpressionEngine, it automatically creates some default templates and categories for you, among other things. But since I like my clean installations really spotless, I created some sql queries to clean up your clean install.

What does it do?

The queries will truncate some tables and insert some defaults that I work with regularly:

  • Delete all template groups and insert a new one: home
  • Delete all templates and insert a new one in home: index
  • Delete all html-buttons and insert buttons for <h2>, <h3>, <strong> and <em>; usually all the formatting an editor would need
  • Delete all categories and category groups
  • Delete all weblog entries
  • Delete all but one weblog fields

That’s it. You could probably do more, but this gives me a great start for new projects.

The SQL

# get rid of template groups
TRUNCATE TABLE exp_template_groups;
INSERT INTO exp_template_groups (group_id,site_id,group_name,group_order,is_site_default,is_user_blog) VALUES (NULL,'1','home','1','y','n');

# get rid of templates
TRUNCATE TABLE exp_templates;
INSERT INTO exp_templates (template_id,site_id,group_id,template_name,save_template_file,template_type,template_data,template_notes,edit_date,cache,refresh,no_auth_bounce,enable_http_auth,allow_php,php_parse_location,hits) VALUES (NULL,'1','1','index','n','webpage','','','0','n','','','n','n','o','');

# better html buttons
TRUNCATE TABLE exp_html_buttons;
INSERT INTO exp_html_buttons VALUES (1, 1, 0, 'strong', '<strong>', '</strong>', 'b', 4, '1');
INSERT INTO exp_html_buttons VALUES (2, 1, 0, 'em', '<em>', '</em>', 'i', 3, '1');
INSERT INTO exp_html_buttons VALUES (3, 1, 0, 'h3', '<h3>', '</h3>', '3', 2, '1');
INSERT INTO exp_html_buttons VALUES (4, 1, 0, 'h2', '<h2>', '</h2>', '2', 1, '1');

# no categories please
TRUNCATE TABLE exp_category_posts;
TRUNCATE TABLE exp_categories;
TRUNCATE TABLE exp_category_groups;
TRUNCATE TABLE exp_category_field_data;

# no weblog entries please
TRUNCATE TABLE exp_weblog_titles;
TRUNCATE TABLE exp_weblog_data;
TRUNCATE TABLE exp_weblog_fields;

# just one weblog field
INSERT INTO exp_weblog_fields VALUES (1, 1, 1, 'body', 'Body', '', 'textarea', '', 'n', 0, 0, 'blog', 0, 'date', 'desc', 0, 10, 0, 'n', 'ltr', 'y', 'n', 'xhtml', 'y', 1);
ALTER TABLE exp_weblog_data DROP field_id_2, DROP field_ft_2, DROP field_id_3, DROP field_ft_3;

Comments

  1. author
    1 Steven Hambleton 2 december 2007, 19:27

    This is great Low!

    Is it possible to change other settings like changing to Cookies instead of Sessions and Cookies?

    I don’t know a lot about SQL or databases so a cheat sheet would be great (if it existed).

  2. author
    2 Low 2 december 2007, 19:45

    @Steven: I’m afraid not. Those settings are saved as serialized arrays, so you’d need some php to decode and encode them. Not something you could do properly with mysql only.

  3. author
    3 Steven Hambleton 2 december 2007, 19:53

    Well what you have done here is highly useful! Especially setting the HTML buttons. I use Markdown for text formatting so this will save a lot of time!

    And also it will help with setting up template groups for includes etc.

  4. author
    4 Deron Sizemore 7 december 2007, 21:17

    I’m a novice when it comes to MySQL queries stuff…so, with that said, how do I use these queries to clean up my install?

    Just go to phpMyAdmin and copy/paste this code above somewhere?

    Thanks

  5. author
    5 Brice Irvine 8 december 2007, 18:33

    Ditto. How does one go about making this MySQL query to the EE database?

    Thanks

  6. author
    6 Low 8 december 2007, 19:04

    You can either copy and paste the code into phpMyAdmin, or save the code as a file (plain text) and run it from de mysql command line. If you’re a developer who installs EE on a regular basis, you’ll probably know what to do.

  7. author
    7 Ryan Blaind 13 december 2007, 20:54

    I ran this query on a fresh install of 1.6.1 and when I went to the templates tab after that it says “No templates available” .. just an FYI that something may be off with your query. The only thing I changed was the name of the new default template group changed from “home” to “global” .. ran it in phpmyadmin right after installing without even logging into the cp..

  8. author
    8 Low 13 december 2007, 21:49

    @Ryan: I just did the exact same thing, but everything went fine. Can you verify that the template group and template were created in phpMyAdmin?

  9. author
    9 Philip 19 december 2007, 20:34

    Thanks for the SQL! I do pretty much the same clean up you do after every EE install, I use to do it by importing templates, but this does the same thing, with less pain! Thanks again!

  10. author
    10 Ty (tzmedia) 24 december 2007, 21:26

    Awesome stuff Low… especially the SQL script, there’s no use messing around, when you can just lay the smack-down on it!

  11. author
    11 bjorn/ee 26 december 2007, 16:50

    so simple, yet so effective. Love it, thanks :-)

Leave a comment

Some html (a, em, strong, etc) allowed.


Zoeken in loweblog.com