定制 amowogbaje/database-repository 二次开发

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

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

amowogbaje/database-repository

最新稳定版本:v1.0.3

Composer 安装命令:

composer require amowogbaje/database-repository

包简介

A repository for database backup and seeding operations.

README 文档

README

A Laravel package for handling database operations including data backup, data restoration, and seeding. This package allows you to back up all tables in the database and seed data from JSON files.

Installation

You can install the package via Composer:

$ composer require amowogbaje/database-repository

Usage

php artisan data:backup

Migrating with Seeding Data

Your DatabaseSeeder.php should look like this;

<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

use Amowogbaje\DatabaseRepository\DataRepository;

class DatabaseSeeder extends Seeder
{
    public function run()
    {
        $seed = new DataRepository;
        $tableArray = $seed->getAllTablesInADB();
        foreach ($tableArray as $table) {
            $seed->setTableName($table);
            $seed->dataTableSeederFunction();
        }
    }
}

Anytime you migrate remember to put --seed at the end, it will look like you never dropped the table

php artisan migrate:fresh --seed 

Warning: Be sure your migrations are well written to avoid non-nullable errors for empty fields

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-05