> For the complete documentation index, see [llms.txt](https://githubichsan.gitbook.io/journal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://githubichsan.gitbook.io/journal/wordpress-development/hooks/actions/template-actions/after_switch_theme.md).

# after\_switch\_theme

run after theme actived, used for migrating table after theme actived.

```php
add_action("after_switch_theme", "mytheme_create_extra_table");

function mytheme_create_extra_table(){
    global $wpdb;

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

    $sql = "CREATE TABLE wp_tesaja (
      id int(10) unsigned NOT NULL AUTO_INCREMENT,
      identifier varchar(255) NOT NULL,
      translation varchar(255) NOT NULL,
      lang varchar(5) NOT NULL,
      notes varchar(255) DEFAULT NULL,
      PRIMARY KEY  (id),
      KEY Index_2 (lang),
      KEY Index_3 (identifier)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";

    dbDelta( $sql );
}
```
