PHPackages                             owenmelbz/forget-db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. owenmelbz/forget-db

ActiveProject[Database &amp; ORM](/categories/database)

owenmelbz/forget-db
===================

A simple GDPR inspired tool to anonymise confidential database data.

1.0.2(5y ago)139247[1 issues](https://github.com/OwenMelbz/forget-db/issues)[4 PRs](https://github.com/OwenMelbz/forget-db/pulls)MITPHPPHP ^7.1.3

Since May 26Pushed 3y ago3 watchersCompare

[ Source](https://github.com/OwenMelbz/forget-db)[ Packagist](https://packagist.org/packages/owenmelbz/forget-db)[ Docs](https://github.com/OwenMelbz/forget-db)[ RSS](/packages/owenmelbz-forget-db/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (11)Versions (26)Used By (0)

🧠 forget-db
===========

[](#-forget-db)

[![Build Status](https://camo.githubusercontent.com/42d1ed633b34c169e9ae22defb6a2d3486567fa82ea0493b2fdd493e415a5a01/68747470733a2f2f7472617669732d63692e6f72672f4f77656e4d656c627a2f666f726765742d64622e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/OwenMelbz/forget-db)

A simple(ish) command line tool written in PHP 7.4 using Laravel Zero and Faker to help you anonymise/pseudonymise data within your database to support protecting either sensitive information, or peoples right to be forgotten with GDPR compliance.

The tool allows you to connect to either mysql, postgres, sqlite or sqlserver and replace defined information with random data to allow you to keep statistics/relationships/audit of actions etc.

It uses a simple yaml configuration file to define the conditions for overwriting, which fields you want to overwrite, and what to overwrite them with.

Installation
============

[](#installation)

I would recommend installing this globally on your system:

```
composer global require -W owenmelbz/forget-db
```

Alternatively you can install this with curl:

```
curl -L https://github.com/OwenMelbz/forget-db/raw/master/builds/forget-db
chmod +x forget-db
mv ./forget-db /usr/local/bin/forget-db
forget-db update # optional - but will make sure your binary is up to date
```

Configuration
=============

[](#configuration)

To generate a new config just run (from anywhere) `forget-db new`

This will walk you through generating an example config file.

This will generate a basic config file that looks something like:

```
table_one:
    key: user_id
    conditions: ['where user_id != 1', 'or user_email LIKE "%@%"']
    columns: { user_name: name, user_email: email }
table_two:
    key: user_id
    columns: { user_name: name, user_email: email }
table_three:
    key: user_id
    conditions: 'table_two.user_id = 1'
    joins: 'table_two on table_two.user_id = table_three.table_two_id'
    columns: { user_name: name, user_email: email }
```

Properties
----------

[](#properties)

Each top level item in the config file is a database table e.g `table_one`

The first **required** property is `key` this is very important as it defines which column is used for the update query and most likely needs to be unique.

The second **required** property is `columns` this is simply an array of column names, with their values set to Faker methods, you can get a full list of generators [Faker Generators here](https://github.com/fzaninotto/Faker) - most are easy to remember such as `name, email, company` etc. You can also use parametrized formatters like `regexify`.

The first **optional** property is `conditions` this should be an array of sql clauses if you need to restrict usage, e.g if you only need user\_id 1 to be forgotten, then you can add `where user_id = 1`. You should be able to have multiple conditions, these get passed into Laravels' `whereRaw` method, so check out those documents if you need more advance queries.

The second **optional** property is `joins` this can be a string or array of joins which will be used to accompany the conditions, it takes a simple join query in the following format `joined_table on joined_table.column = other_table.column`, you can use the modifier system to prefix a table with a join type, e.g `left:tablename on...` this gets passed to Laravel's `leftJoin()`, `rightJoin()` and `join()` functions.

Modifiers
---------

[](#modifiers)

Recently we introduced the ability to add modifiers to your column definitions, currently there is only one. To use a modifier just prefix the faker method with `modifier:` to create something like `modifier:email_address`

NameDescriptionunique:Will utilise Fakers unique() method to generate unique data for a columnleft/right:Allows you to define the type of join to executeUsage
=====

[](#usage)

Once you have your config complete you can run `forget-db forget ./path/to/config.yml`. The wizard will ask for your connection details, and then will start the cleanse. If you specify database connection parameters in file named `.env` placed in the working directory, those values are automatically used by the code. See `.env.example` to learn more about the settings that can be configured this way. Note that in interactive mode, the environment being used at runtime (as specified using the `--env` switch) affects the defaults. In non-interactive mode, all yes/no questions default to yes, regardless of the environment setting. To run in non-interactive mode, use the `-n` switch (useful for scripted runs).

After the command is completed you'll get some output about the success of the operation (with a detailed error message as appropriate). The code returns `0` exit code on success and `1` on failure.

Dry-run
-------

[](#dry-run)

We do not have a full dry-run system, however you can preview the query that selects your data set, and a table of the data that it has found, simply specify the `--dry` arg after your command e.g `forget-db forget ./config --dry`. This will only run "selects" on your database and will not write any changes! You will see something similar to:

```
🧠  forget-db :: 2 rows found to process.
🧠  forget-db :: Query run... select `users`.`id`, `users`.`email`, `users`.`password` from `users`

+----+-------------------------+------------------+
| id | email                   | password         |
+----+-------------------------+------------------+
| 1  | arvel.bradtke@auer.com  | 371817583255573  |
| 2  | remington54@volkman.org | 6011543368953199 |
+----+-------------------------+------------------+

```

Limitations for dry-runs:

- It won't give you what the data will look like AFTER you run `forget`
- It won't give you the update commands it will run

> Warning - When doing a dry run, remember that it will output to your terminal, so if you are exposing sensitive data make sure you're taking the correct precautions!

Warnings / Notes
================

[](#warnings--notes)

- Due to syntax and Laravel requirements running the code requires PHP 7.1+
- There is no full dry-run support, I recommend to test this on a temporary database first or test your conditions using the `--dry` arg
- The system that is running the tool must have a connection to the database server (firewall rules and ACLs might need to be set accordingly).
- Due to trying to keep optimal server compatibility, updates are not done in bulk, but are done one at a time, so make sure you're aware of any row/table locking on your server.
- For large datasets, dry-running might crash depending on resource limits set in your local php environment. In interactive mode, the code asks whether you want to go on or not if more than 50 records are to be fetched.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 58% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~53 days

Recently: every ~256 days

Total

21

Last Release

1855d ago

Major Versions

0.1.0 → 1.0.02020-01-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/672fbfa799365c6b8e334b066ad674e06ed4c6d68536ad2fe9be3bd565b5c601?d=identicon)[OwenMelbz](/maintainers/OwenMelbz)

---

Top Contributors

[![OwenMelbz](https://avatars.githubusercontent.com/u/1094740?v=4)](https://github.com/OwenMelbz "OwenMelbz (51 commits)")[![kissg1988](https://avatars.githubusercontent.com/u/5032340?v=4)](https://github.com/kissg1988 "kissg1988 (33 commits)")[![0xflotus](https://avatars.githubusercontent.com/u/26602940?v=4)](https://github.com/0xflotus "0xflotus (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![infostreams](https://avatars.githubusercontent.com/u/1132744?v=4)](https://github.com/infostreams "infostreams (1 commits)")

---

Tags

databasegdprlaravelclilaraveldatabasegdpr

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/owenmelbz-forget-db/health.svg)

```
[![Health](https://phpackages.com/badges/owenmelbz-forget-db/health.svg)](https://phpackages.com/packages/owenmelbz-forget-db)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[guidocella/eloquent-populator

Guess attributes for Eloquent model factories

7661.6k2](/packages/guidocella-eloquent-populator)[mvanduijker/laravel-model-exists-rule

Validation rule to check if a model exists

22194.5k1](/packages/mvanduijker-laravel-model-exists-rule)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3418.6k](/packages/dragon-code-laravel-data-dumper)[boaideas/laravel-cli-create-user

An artisan command to create, list and remove users in a laravel application from the cli

1610.7k](/packages/boaideas-laravel-cli-create-user)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
