This project provides a command-line tool for copying specific entries from a production database to a development database, ensuring that only the necessary data is copied. This is particularly useful for investigating bugs that only occur with production data without having to copy the entire production database.
- Copy a specific feed entry and its associated data.
- Option to copy only certain source entries (e.g., Instagram or TikTok).
- Option to include a specific number of posts associated with the feed.
- Unit tests to ensure the functionality of the CLI tool.
- PHP 8.2 or higher
- Laravel 11 or higher
- Composer
-
Clone the repository:
git clone https://github.com/amiralikh/copy-command-tool.git cd copy-command-tool -
Install dependencies:
composer install
-
Set up environment:
Copy the
.env.exampleto.envand update the database configurations.cp .env.example .env
-
Run migrations:
php artisan migrate
-
Run tests to ensure everything is set up correctly:
php artisan test
The command-line tool provides several options for copying data:
-
Copy a feed with ID 123:
php artisan copy:feed 123
-
Copy a feed with ID 123 and its Instagram source:
php artisan copy:feed 123 --only=instagram
-
Copy a feed with ID 123, its Instagram source, and 5 associated posts:
php artisan copy:feed 123 --only=instagram --include-posts=5
--only: Specifies which source to copy (instagramortiktok).--include-posts: Specifies the number of posts to copy.
The project includes comprehensive unit tests to ensure the functionality of the CLI tool. The tests cover various scenarios, including:
- Copying a feed without any sources or posts.
- Copying a feed with Instagram or TikTok sources.
- Copying a feed with a specified number of posts.
- Handling non-existent feed IDs.
Run the tests using Pest:
php artisan testThe test suite includes the following scenarios:
- copies a feed without any sources or posts
- copies feed with instagram source only
- copies feed with tiktok source only
- copies feed with posts only
- copies feed with instagram source and specified number of posts
- copies feed with tiktok source and specified number of posts
- copies feed with all sources and posts
- fails when feed does not exist
- copies feed with zero posts when include-posts is zero
- copies feed with instagram source and specified number of posts explicitly
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License.
For any questions or support, please open an issue or contact amirali-kh@live.com.