<commit_before>Exodus
====================

Exodus is a content migration library that allows you to dynamically create content migrations.

## Installation
This module can be easily installed by adding `10up/exodus` to your `composer.json` file. Then, either autoload your Composer dependencies or manually `include()` the `Exodus.php` bootstrap file.

Exodus requires WP-CLI. Install it by following [these instructions](http://wp-cli.org).

> Currently the library only support json migrations but im planning on
> on creating parsers for sql and xml.

## Creating a Migration Schema Files
```bash
wp exodus schema my_first_migration --type=json
```

**Other available configurations:**

*  `<name>` The name of your migration
* `--type` The type of migration. You can use json, sql or xml
* `[--post_types]` Comma delimited list of the post types that will be imported. By default it will only do post
* `[--site]` The id of the site you are migrating content to.
* `[--iterator]` The nesting of where the post are in your import file
* `[--report]` Name of the url parameter in your import file in order to export a csv of old to new urls
* `[--verify]` Percent ( 1-100 ) of random post to verify that were imported successfully

### Adding a Schema Map

Sample JSON import file
```bash
[{
"timestamp": 1408464060,
"title": "Test title",
"body": "Body content",
"post_url": "http://test.com/test-title/",
"post_id": 1234,
"tags" : [ "Tag 1", "Tag 2"]
},{
"timestamp": 1408677660,
"title": "Test title 2",
"body": "Body content 2",
"post_url": "http://test.com/test-title-2/",
"post_id": 1234,
"tags" : []
}]'
```

```bash
Map::factory()->create( 'post', function ( $data ) {
	$data->post_title( 'title' );
	$data->post_content( 'body' );
	$data->post_date( 'timestamp' );
	$data->meta_data( 'post_url', 'post_url' );
	$data->meta_data( 'post_id', 'id' );
	$data->taxonomy( 'post_tag', 'tags' );
} );
```

** Available Schema Commands: **

`$key` stands for the key that the WordPress attribute represents in your content. For example in the JSON above the key for the post_content is "body".

`$meta_key` stands for the key the meta data will have in WordPress.

`$taxonomy` stands for the taxonomy label inside of WordPress.


| Commands                             | Description                               |
| ------------------------------------ | ----------------------------------------- |
| $data->post_type( $key );            | Map the post type attribute               |
| $data->post_title( $key );           | Map the post title attribute              |
| $data->post_content( $key );         | Map the post content attribute            |
| $data->post_author( $key );          | Map the post author attribute             |
| $data->post_excerpt( $key );         | Map the post excerpt                      |
| $data->post_date( $key );            | Map the post date                         |
| $data->post_date_gmt( $key );        | Map the post date GMT                     |
| $data->meta_data( $meta_key, $key ); | Map the meta data. One for each data set. |
| $data->taxonomy( $taxonomy, $key );  | Map the taxonomy. One for each taxonomy.  |

## Run a Migration
```bash
wp exodus schema my-first-migration --file=test-migration.json
```
** Available configurations: **<commit_msg>fix bold tags<commit_after>Exodus
====================

Exodus is a content migration library that allows you to dynamically create content migrations.

## Installation
This module can be easily installed by adding `10up/exodus` to your `composer.json` file. Then, either autoload your Composer dependencies or manually `include()` the `Exodus.php` bootstrap file.

Exodus requires WP-CLI. Install it by following [these instructions](http://wp-cli.org).

> Currently the library only support json migrations but im planning on
> on creating parsers for sql and xml.

## Creating a Migration Schema Files
```bash
wp exodus schema my_first_migration --type=json
```

**Other available configurations:**

*  `<name>` The name of your migration
* `--type` The type of migration. You can use json, sql or xml
* `[--post_types]` Comma delimited list of the post types that will be imported. By default it will only do post
* `[--site]` The id of the site you are migrating content to.
* `[--iterator]` The nesting of where the post are in your import file
* `[--report]` Name of the url parameter in your import file in order to export a csv of old to new urls
* `[--verify]` Percent ( 1-100 ) of random post to verify that were imported successfully

### Adding a Schema Map

Sample JSON import file
```bash
[{
"timestamp": 1408464060,
"title": "Test title",
"body": "Body content",
"post_url": "http://test.com/test-title/",
"post_id": 1234,
"tags" : [ "Tag 1", "Tag 2"]
},{
"timestamp": 1408677660,
"title": "Test title 2",
"body": "Body content 2",
"post_url": "http://test.com/test-title-2/",
"post_id": 1234,
"tags" : []
}]'
```

```bash
Map::factory()->create( 'post', function ( $data ) {
	$data->post_title( 'title' );
	$data->post_content( 'body' );
	$data->post_date( 'timestamp' );
	$data->meta_data( 'post_url', 'post_url' );
	$data->meta_data( 'post_id', 'id' );
	$data->taxonomy( 'post_tag', 'tags' );
} );
```

**Available Schema Commands:**

`$key` stands for the key that the WordPress attribute represents in your content. For example in the JSON above the key for the post_content is "body".

`$meta_key` stands for the key the meta data will have in WordPress.

`$taxonomy` stands for the taxonomy label inside of WordPress.


| Commands                             | Description                               |
| ------------------------------------ | ----------------------------------------- |
| $data->post_type( $key );            | Map the post type attribute               |
| $data->post_title( $key );           | Map the post title attribute              |
| $data->post_content( $key );         | Map the post content attribute            |
| $data->post_author( $key );          | Map the post author attribute             |
| $data->post_excerpt( $key );         | Map the post excerpt                      |
| $data->post_date( $key );            | Map the post date                         |
| $data->post_date_gmt( $key );        | Map the post date GMT                     |
| $data->meta_data( $meta_key, $key ); | Map the meta data. One for each data set. |
| $data->taxonomy( $taxonomy, $key );  | Map the taxonomy. One for each taxonomy.  |

## Run a Migration
```bash
wp exodus schema my-first-migration --file=test-migration.json
```
**Available configurations:**
{'fraction_non_alphanumeric': 0.15889830508474576, 'fraction_numerical': 0.011803874092009685, 'mean_word_length': 2.8048359240069085, 'pattern_counts': {'":': 20, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1609952', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1892, 'n_words': 740}