edisonlabs/database_sanitize
Composer 安装命令:
composer require edisonlabs/database_sanitize
包简介
Provides drush commands for yaml sanitization files checks and generation.
README 文档
README
Database Sanitize
Overview
Provides a set of drush commands to assist in generating a database.sanitize.yml file containing all the queries for database sanitization.
Commands included
db-sanitize-analyze (dbsa)Compares existingdatabase.sanitize.ymlfiles on the site installation against existing database tables and list tables that needs to be verified and possibly sanitized.db-sanitize-generate (dbsg)generates adatabase.sanitize.ymlfile for all tables not specified indatabase.sanitize.ymlfiles.
Use the option --file to specify a YML file and skip the scan.
This is meant to be used alongside merge-yaml composer plugin, so that when you build your local environment for a drupal site, an database.sanitize.merge.yml file will be generated. This file's path is what you're expected to pass in.
Usage instructions
You can provide a database.sanitize.yml file containing queries for database sanitization for your module or profile.
File format
sanitize:
MACHINE_NAME:
DBTABLENAME1:
description: 'query description'
query: 'DB QUERY 1'
DBTABLENAME2:
description: 'query description'
query: 'DB QUERY 2'
MACHINE_NAME2:
DBTABLENAME3:
description: 'query description'
query: 'DB QUERY 3'
DBTABLENAME4: false
DBTABLENAMEPREFIX*: false
Using a wildcard * for table names is supported. For example, setting node_revision* will apply to all tables names starting with node_revision.
Commands usage
To find out how many tables needs to be defined in database.sanitize.yml files:
drush dbsa
# Specifying a file.
drush dbsa --file=/var/www/SITE/NON-PUBLIC-FOLDER/database.sanitize.merge.yml
To get the YAML file content for the missing tables to be sanitized:
drush dbsg --machine-name="my_module"
To save the missing tables to a database.sanitize.yml file:
drush dbsg --machine-name="MY_profile" > docroot/profiles/MY_profile/database.sanitize.yml
The generated queries for each missing table default to TRUNCATE TABLE $table. Developers are expected to assess what content should be sanitized for each table and edit the file accordingly.
Automated Tests and Code Sniffer
This repository is integrated with Travis CI to perform tests and detect Drupal coding standards violations.
Running tests locally for development
You will need to:
- Run composer install.
- Run composer install inside the
vendor/drush/drushdirectory. - Within the root of the package, run this command adjusting
UNISH_DB_URLwith your database configuration.
UNISH_DB_URL="mysql://USERNAME:PASSWORD@127.0.0.1" UNISH_NO_TIMEOUTS=y vendor/drush/drush/vendor/bin/phpunit --configuration "vendor/drush/drush/tests" drush/tests/
edisonlabs/database_sanitize 适用场景与选型建议
edisonlabs/database_sanitize 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.6M 次下载、GitHub Stars 达 5, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 edisonlabs/database_sanitize 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 edisonlabs/database_sanitize 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.6M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2026-01-04