2017 © Pedro Peláez
 

library db-archive-bundle

Bundle to archive database tables using different strategies

image

sarelvdwalt/db-archive-bundle

Bundle to archive database tables using different strategies

  • Monday, November 2, 2015
  • by sarelvdwalt
  • Repository
  • 2 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

SFArchiveBundle

Purpose

The purpose of this bundle is to provide a generic Symfony2 Console Command which is used to archive DB tables. The general idea is that you give it a table name, and a strategy that it should follow to archive., (*1)

Say you have 100 000 000 records in a table called "stuff". Let's assume for a second that the table called "stuff" has a created_at field attached to it, which is a date-time field in MySQL (or whatever your underlying database is)., (*2)

When calling the command php app/console archive:generic stuff it will run through the table stuff and archive the values into tables starting with a "z" and ending in the "Ym" value corresponding to the record's created_at column., (*3)

As an example, a record having created_at of "2014-03-11 23:54:22" will be archived to the table with name zstuff201403. And record having created_at of "2014-02-28 08:23:00" will go to zstuff201402 - notice the difference is in the month at the end., (*4)

The rational behind this is that tables starting with z will be at the end of your list of tables, in an effort to avoid cluttering your main view of your database., (*5)

Usage

Usage:
 archive:generic [--days="..."] [--strategy-z-tables[="..."]] [--strategy-source-field="..."] [--batch-size[="..."]]
 [--source-entity-manager="..."] [--destination-entity-manager="..."] table_name

Arguments:
 table_name                    The name of the source table to archive

Options:
 --days                        Defines how many days in the past to start archive.
                               Example, 14 would archive data older than 14 days (default: 90)
 --strategy-z-tables           Strategy is to create tables of the same name, in format zTableNameYm
                               (ex zclients201403. (default: "Ym")
 --strategy-source-field       Field to base the strategy on. For the YYYYMM strategy, this has to be
                               a date field (default: "created_at")
 --batch-size                  Size of each batch. It is important not to choose too big or small a batch.
                               Big batches will cause memory problems, small ones will decrease the
                               speed of archiving. (default: 100)
 --source-entity-manager       Source Entity Manager to archive from (default: "default")
 --destination-entity-manager  Destination Entity Manager to archive to. If none is provided,
                               the same as --source-entity-manager will be used. (default: "default">

Reporting an issue or a feature request

Please submit issues and feature requests in the Github issue tracker., (*6)

The Versions

02/11 2015

dev-master

9999999-dev

Bundle to archive database tables using different strategies

  Sources   Download

MIT

The Requires

 

by Sarel van der Walt

05/03 2015

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1

Bundle to archive database tables using different strategies

  Sources   Download

MIT

The Requires

 

by Sarel van der Walt

17/10 2014

dev-develop

dev-develop

Bundle to archive database tables using different strategies

  Sources   Download

MIT

The Requires

 

by Sarel van der Walt