Giter Club home page Giter Club logo

rumble's Introduction

Rumble

A php migration tool for AWS dynamoDB.

Requirements

To use rumble for migration and seeding, you should either have aws dymanodb locally installed or have a valid aws credential for the remote version in a particular aws region.

Disclosure

rumble is far from being complete compared to other migration tool out there. More features will be added in the future.

Naming Convention

Since rumble is still in its infancy, it cannot generate migration or seeder file automatically. You have to manually create files for both migrations and seeds. Migration and Seed files are to be placed in migrations and seeds directories at the root of your project.

A migration or seed file must be named with an underscore (_) separating each word that makes up the file name. e.g: creat_app_records_table.php, is a valid file name for a migration or a seed file.

While the file name uses underscore (_) naming style, the class name for the creat_app_records_table.php file uses PasCal naming style. i.e the first letter of every word that makes up the file name must be capitalized e.g: CreateAppRecordsTable.

Class Definition

  • Migration: Every migration file (class) you create must extend the rumble Migration class and must define a up method.
  • Seed: Every seed file (class) you create must extend the rumble Seeder class and must define a seed method.

Using Rumble

  • Migration: to migrate files, run rumble migrate from the root directory of your project. e.g: vendor/bin/rumble migrate
  • Seed: to seed files, run rumble seed from the root directory of your project e.g vendor/bin/rumble seed

Supported DynamoDb Features

Currently, rumble supports only the below dynamodb features;

  • Create table
  • Update table
  • Delete table
  • Add Item
  • Batch Write Item

Tutorial - Create a new table

The below code sample shows the minimum required params to create a dynamodb table using rumble. This is from the up method of the migration file (create_app_records_table.php). The up method, is the only required method to be implemented by every migration file you create.

<?php
use Rumble/Migration;

class CreateAppRecordsTable extends Migration
{
    public funtion up()
    {
        $table = $this->table('app_records'); //table name
        $table->addAttribute('app_uid', 'S'); //primary key data type - String(S)
        $table->addHash('app_uid');  //primary key
        $table->setWCU(10); //Write Capacity Unit (Provisioned write throughPut)
        $table->setRCU(10); //Read Capacity Unit (Provisioned read throughPut)
        $table->create();  //create table
    }
}

Tutorial - Seed table

The below sample code shows the minimum required params to seed a dynamodb table (sample created above). This is from the seed method of the seed file (app_records_seeder.php). The seed method is the only required method to be implemented by every seed file you create

<?php
use Rumble/Seeder;

class AppRecordsTableSeeder extends Seeder 
{
    public function seed()
    {
        $table = $this->table('app_records');
        $table->addItem(['app_uid' => 'x435-n956-00jX-u2fX', 'uninstall' => ['reason' => 'Still thinking of one.']);
        $table->addItem(['app_uid' => '944-jjU0-o0Hi-y4hh4', 'events' => ['action' => 'click', 'date' => '2017-04-10']]); 
        $table->save();
    }
}

Database Configuration

rumble uses a rumble.php file as its configuration file. You have to create this file at the root of your project. This file must return an array with your dynamodb configuration. e.g:

<?php

return [
    'region' => '',
    'key' => '',
    'secret' => '',
    'endpoint' => ''
 ];

rumble's People

Contributors

en0ma avatar piggyamit avatar hongshaoroucook avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.