matasarei / rumble
A DynamoDB migration bundle for Symfony 4
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 8
Type:symfony-bundle
Requires
- aws/aws-sdk-php: ^3.0
- symfony/console: ^4.0
- symfony/framework-bundle: ^4.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-06-09 20:30:55 UTC
README
A DynamoDB migration bundle for Symfony 4 based on original Rumble lib.
Class definition
- Migration: Every migration file (class) you create must extend the rumble
Migration
class and must define anup
method. - Seed: Every seed file (class) you create must extend the rumble
Seeder
class and must define aseed
method.
Using Rumble
- Migration: to apply migrations, run
./bin/console rumble:migrate
- Seed: to execute seed files, run
./bin/console rumble:seed
Supported DynamoDB features
Currently, rumble
supports only the below dynamodb features:
- Create table
- Update table
- Delete table
- Add Item
- Batch Write Item
Installation
-
Add bundle to your project:
composer require matasarei/rumble
-
Add config file:
config/packages/rumble.yaml
With default content:
rumble: migrations_dir: 'migrations' # <project_root>/migrations/... (optional) seeds_dir: 'seeds' # <project_root>/seeds/... (optional) version: '2012-08-10' # (default, optional) region: 'dev' key: 'dev' secret: 'dev' endpoint: 'http://dynamodb:8000'
You can also override values by adding additional configurations to:
config/packages/dev/rumble.yaml
fordev
environment;config/packages/test/rumble.yaml
fortest
\qa
environment;config/packages/prod/rumble.yaml
forprod
environment.
Create a new table
<?php // migrations/CreateAppRecordsTable.php use Matasar\Bundle\Rumble\Migration; class CreateAppRecordsTable extends Migration { public function up() { $table = $this->table('test_table'); // table name. $table->addAttribue('test_field', 'S'); // primary key data type - String (S) $table->addHash('test_field'); $table->setWCU(1); // Write Capacity Unit (Provisioned write throughput) $table->setRCU(1); // Read Capacity Unit (Provisioned read throughput) $table->create(); } }
You can change write \ read capacity later in table settings \ DynamoDB console or setup auto scaling.
Seed table
<?php // seeds/CreateAppRecordsTable.php use Matasar\Bundle\Rumble\Seeder; class AppRecordsTableSeeder extends Seeder { public function seed() { $table = $this->table('test_table'); $table->addItem(['test_field' => 'First record']); $table->addItem(['test_field' => 'Second record']); $table->save(); } }