Schema Template

Schema Template allows Workspace Admin or DBA to pre-define templates of fields and tables at the workspace level, and they may be used to change schema via Schema Editor. There're three types:

  • Field Template
  • Table Template
  • Column Type Restriction

Field Template

  1. Click Settings icon on the top right, and click Schema Template under Security & Policy.
  2. Under Field Template, click Add Field Template and you'll see the Field Template form.
  3. Fill the form as below and click Create:
    • Category: test
    • Engine: PostgreSQL
    • Column name: created_at
    • Column type: DATE
    • Default: Keep it empty and keep Nullable unchecked.

bb-schema-template-field-add

  1. Go to a project and click Edit Schema. Choose a PostgreSQL database and click Next.
  2. Chooose a table on Schema Editor, and click Add from template.

bb-schema-editor-add-from-template-field

  1. Select the created_at template you just created, and it will be appended in the table.

Table Template

  1. Click Settings icon on the top right, and click Schema Template under Security & Policy.
  2. Under Table Template, click Add Table Template and you'll see the Table Template form.
  3. Fill the form as below and click Create:
    • Category: test
    • Engine: PostgreSQL
    • Table name: user
    • Add column:
      • Column name: id
      • Column type: INTEGER
      • Default: EMPTY
      • Not Null: Checked
      • Primary: Checked
    • Add column:
      • Column name: name
      • Column type: VARCHAR(45)
      • Default: EMPTY
      • Not Null: Checked
      • Primary: Unchecked
    • Add from template:
      • Template: created_at

bb-schema-template-table-add

  1. Go to a project and click Edit Schema. Choose a PostgreSQL database and click Next.
  2. Chooose a database on Schema Editor, and click Add from template.

bb-schema-editor-add-from-template-table

  1. Select the user template you just created, and the new table will be appended in the table list on the left.

Column Type Restriction

  1. Click Settings icon on the top right, and click Schema Template under Security & Policy.
  2. Under Column Type Restriction, choose Allow limited types and you'll see allowed type list. Remove VARCHAR(255) and click Update.
  3. Go to a project and click Edit Schema. Choose a PostgreSQL database and click Next.
  4. Chooose a table on Schema Editor, choose an existing row, click Type dropdown and you'll see VARCHAR(255) is not available.

bb-schema-editor-type-dropdown

Edit this page on GitHub

Subscribe toΒ Newsletter

By subscribing, you agree with Bytebase's Terms of Service and Privacy Policy.