定制 staudenmeir/laravel-migration-views 二次开发

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

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

staudenmeir/laravel-migration-views

Composer 安装命令:

composer require staudenmeir/laravel-migration-views

包简介

Laravel database migrations with SQL views

README 文档

README

CI Code Coverage PHPStan Latest Stable Version Total Downloads License

This Laravel extension adds support for SQL views in database migrations.

Supports Laravel 5.5+.

Installation

composer require staudenmeir/laravel-migration-views:"^1.0"

Use this command if you are in PowerShell on Windows (e.g. in VS Code):

composer require staudenmeir/laravel-migration-views:"^^^^1.0"

Versions

Laravel Package
13.x 1.12
12.x 1.11
11.x 1.9
10.x 1.7
9.x 1.6
8.x 1.5
7.x 1.4
6.x 1.2
5.8 1.1
5.5–5.7 1.0

Usage

Creating Views

Use createView() to create a view and provide a query builder instance or an SQL string:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

$query = DB::table('users')->where('active', true);

Schema::createView('active_users', $query);

You can provide the view's columns as the third argument:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

$query = 'select id from users where active = 1';

Schema::createView('active_users', $query, ['key']);

Use createOrReplaceView() to create a view or replace the existing one:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

$query = DB::table('users')->where('active', true); 

Schema::createOrReplaceView('active_users', $query);

View Processing Algorithm

On MySQL and MariaDB, you can specify the view processing algorithm:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

$query = DB::table('users')->where('active', true);

Schema::createView('active_users', $query, algorithm: 'TEMPTABLE');

Renaming Views

Use renameView() to rename a view:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

Schema::renameView('active_users', 'users_active');

Dropping Views

Use dropView() or dropViewIfExists() to drop a view:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

Schema::dropView('active_users');

Schema::dropViewIfExists('active_users');

If you are using php artisan migrate:fresh, you can drop all views with --drop-views (Laravel 5.6.26+).

Checking For View Existence

Use hasView() to check whether a view exists:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

if (Schema::hasView('active_users')) {
    //
}

Listing View Columns

Use getViewColumnListing() to get the column listing for a view:

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

$columns = Schema::getViewColumnListing('active_users');

Materialized Views

On PostgreSQL, you can create a materialized view with createMaterializedView():

use Staudenmeir\LaravelMigrationViews\Facades\Schema;

$query = DB::table('users')->where('active', true);

Schema::createMaterializedView('active_users', $query);

Use refreshMaterializedView() to refresh a materialized view:

Schema::refreshMaterializedView('active_users');

Use dropMaterializedView() or dropMaterializedViewIfExists() to drop a materialized view:

Schema::dropMaterializedView('active_users');
Schema::dropMaterializedViewIfExists('active_users');

Use hasMaterializedView() to check whether a materialized view exists:

if (Schema::hasMaterializedView('active_users')) {
    //
}

Contributing

Please see CONTRIBUTING and CODE OF CONDUCT for details.

staudenmeir/laravel-migration-views 适用场景与选型建议

staudenmeir/laravel-migration-views 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.79M 次下载、GitHub Stars 达 219, 最近一次更新时间为 2019 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 staudenmeir/laravel-migration-views 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 staudenmeir/laravel-migration-views 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.79M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 219
  • 点击次数: 30
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 219
  • Watchers: 3
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-15