npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-pgsql

v0.0.5

Published

A Yeoman generator for PostgreSQL database scripts.

Downloads

3

Readme

generator-pgsql

npm version dependency status

A Yeoman generator for PostgreSQL database scripts.

Demo workspace

Check out the demo_database directory! There you can see how generator-pgsql works.

Workspace structure

generator-pgsql will create the following directory structure while working with the different generators:

Available generators

Quick note: You can remove any generated script using the --wipe flag.

yo pgsql [dbname]

Creates a database script for a database named dbname. This generator will prompt:

  • A database name
  • A username that will be the owning role
  • A password (if the role doesn't exists yet)

The script is pushed into {dbname}/db.sql.

yo pgsql:schema [schemaname]

Creates a schema script. This generator will only prompt for a schema name.

The script is pushed into {dbname}/schemas/{schemaname}.sql.

yo pgsql:table [tablename] [--inherits <table_list> | --like <source_table>] [--fk]

Creates a table script.

This generator will prompt:

  • A table name
  • Whether the table will live in a schema or not
  • If the table shall be in a schema, such schema's name
  • The column definition for the table (as long as the --like flag isn't used)
  • Primary key constraint definition

The script is pushed into {dbname}/tables/{tablename}.sql.

--inherits

This flag add the INHERITS clause to the CREATE TABLE sentence. It accepts a comma-delimited list of tables.

--like

This flag creates a table as a duplicate (LIKE) of a given table. It'll skip the column definition input.

--fk

This flag allows to input foreign keys into the CREATE TABLE script.

yo pgsql:view

Creates a view script, prompting for a view name and its schema relation.

yo pgsql:function

Creates a function script, prompting for:

  • A function name
  • Whether the function will live in a schema or not
  • Function parameters
  • Return type
  • Procedural language
  • Security profile

yo pgsql:sequence

Creates a sequence script, prompting for:

  • The sequence name
  • Whether the sequence will live in a schema or not
  • Minimum and maximum values
  • Increment step
  • Binding to a table column

yo pgsql:build-script [--recompile]

Compiles all of the SQL scripts in a single build.sql file, in this order:

  • Owning role
  • Database
  • Schemas
  • Tables

Also, creates a build.sh bash script that autolocates your psql binary and runs the build file.

Script files are placed in the root of the database folder (dbname/).

--recompile

Instead of creating tables, it will only create views and functions in a recompile.sql script, along with its recompile.sh bash runner.

yo pgsql:wipe

Destroys the workspace, deleting all of the SQL scripts created.

License