定制 edisonlabs/database_sanitize 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

edisonlabs/database_sanitize

Composer 安装命令:

composer require edisonlabs/database_sanitize

包简介

Provides drush commands for yaml sanitization files checks and generation.

README 文档

README

Build Status

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 existing database.sanitize.yml files on the site installation against existing database tables and list tables that needs to be verified and possibly sanitized.
  • db-sanitize-generate (dbsg) generates a database.sanitize.yml file for all tables not specified in database.sanitize.yml files.

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:

  1. Run composer install.
  2. Run composer install inside the vendor/drush/drush directory.
  3. Within the root of the package, run this command adjusting UNISH_DB_URL with 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 edisonlabs/database_sanitize 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.6M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 34
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 6
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2026-01-04