simo46/laravel-postgresql-inherit

为postgresql表添加继承功能

v2.7 2022-05-25 10:48 UTC

This package is not auto-updated.

Last update: 2024-09-26 19:56:40 UTC


README

Software License

为postgresql表添加继承功能

安装

需要PHP 7.2+Laravel 7.x

对于Laravel版本 5.2.* & 5.3.*,运行以下命令通过composer安装此包:

composer require "rishi-ramawat/laravel-postgresql-inherit ~2.1.0"

对于Laravel版本 5.4+,运行以下命令通过composer安装此包:

composer require "rishi-ramawat/laravel-postgresql-inherit ~2.2"

对于Laravel版本 7.x,运行以下命令通过composer安装此包:

composer require "rishi-ramawat/laravel-postgresql-inherit ~2.4"

对于Laravel版本 8.x,运行以下命令通过composer安装此包:

composer require "rishi-ramawat/laravel-postgresql-inherit ~2.6"

一旦安装了PostgreSQL Schema,您需要注册服务提供者。打开 config/app.php 文件,并将以下内容添加到 providers 数组中。

RishiRamawat\PostgresSchema\PostgresqlSchemaServiceProvider::class,

用法

在使用postgresql数据库的迁移文件中,您可以使用新的方法 inherits()

Schema::create('cities', function(Blueprint $table) {
  $table->increments('id');
  $table->string('name');
  $table->double('population');
  $table->integer('altitude')->comment('In Feet');
});

Schema::create('capitals', function(Blueprint $table) {
    $table->string('state');
    // Make capitals table inherits all the columns of its parent table, cities
    $table->inherits('cities');
});