Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Reference Documentation for DDL #66

Open
Tracked by #138
aeneasr opened this issue Nov 26, 2019 · 1 comment
Open
Tracked by #138

Provide Reference Documentation for DDL #66

aeneasr opened this issue Nov 26, 2019 · 1 comment
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@aeneasr
Copy link
Member

aeneasr commented Nov 26, 2019

It would be great to get an overview of all available options for each respective datatype and the full vocabulary.

For example, README.md is missing t.Timestamps().

@stanislas-m stanislas-m added the documentation Improvements or additions to documentation label Mar 1, 2020
@duckbrain
Copy link
Contributor

duckbrain commented Aug 13, 2020

Here's the functions and opts I could find reading the source code. I omitted functions that didn't seem to be relevant to a fizz migration file. I added some descriptions, but it's far from fleshed-out docs.

  • Top-level functions: https://github.com/gobuffalo/fizz/blob/v1.11.0/bubbler.go#L30
    • exec - Execute an External Command
    • create_table - Create a Table
      • opts
        • timestamps - boolean include created_at and updated_at timestamp columns (default: true)
    • change_column
    • add_column
    • drop_column
    • rename_column
    • raw
    • sql
    • add_index
    • drop_index
    • rename_index
    • add_foreign_key
    • drop_foreign_key
      • opts
        • if_exists boollean adds IF EXISTS to SQL if true
    • drop_table
    • rename_table
  • Table functions: https://pkg.go.dev/github.com/gobuffalo/fizz?tab=doc#Table
    • Column(name, type, opts) - Add a column to the table
      • type: documented in README
      • opts
        • null - boolean if column should be nullable (default false)
        • default - Default value of column
        • default_raw - SQL fragment of default value of column
        • size - length of string types
        • precision - precision of decimal types
        • scale - scale of decimal types (ignored if precision not set)
        • first - Make this the first column
        • after - Add this column after the named one
        • primary - Column is one of the primary keys
    • ForeignKey(columnName, foreignKeyRef, opts) - Add a foreign key constraint to a column on the table
      • opts
        • on_update - ON UPDATE SQL fragment
        • on_delete - ON DELETE SQL fragment
    • Index - Adds an index to a column(s) on the table
      • opts
        • name - Give an explicit name to the index
        • unique - Enforce a unique index
    • PrimaryKey(columnNames...) - Marks the named columns as primary keys before adding them to the table.
      • Called after adding the columns
      • Can probably be excluded from docs, since it's redundant with an option on Column
    • DisableTimestamps - Disables timestamps from being added (sets opt to false)
    • Timestamps - Explicitly enables timestamp columns to be added (default)

I used a regex: options\["[a-z_]+"\] to find them.

@sio4 sio4 added this to the v2 milestone Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants