Created
March 20, 2023 10:18
-
-
Save fischerscode/35cd0d07d0e8755b9eb885a86d9bdea8 to your computer and use it in GitHub Desktop.
Serverpod table definition - 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Alternatively, CONSTRAINTs could be represented directly. | |
# This however might require polymorphism. | |
# yaml-language-server: $schema=https://go.fischerscode.com/serverpod-schema | |
### The definition of a (desired) table in the database. | |
class: TableDefinition | |
fields: | |
### The table name | |
tableName: String | |
### All the columns of this table. | |
columns: List<ColumnDefinition> | |
### The elements are the columns. | |
#! See the note at the top of the file. | |
primaryKey: List<String>? | |
### All the foreign keys. | |
#! See the note at the top of the file. | |
foreignKeys: List<ForeignKeyDefinition> | |
### All the indexes of this table. | |
indexes: List<IndexDefinition> | |
--- | |
# yaml-language-server: $schema=https://go.fischerscode.com/serverpod-schema | |
### The definition of a (desired) column in the database. | |
class: ColumnDefinition | |
fields: | |
### The column name | |
name: String | |
### The actual column type | |
columnType: ColumnType | |
### Whether this column is nullable. | |
isNullable: bool | |
# ? Maybe not even needed | |
# ### The (dart) type specified in the yaml file. | |
# ### Is nullable, since this is not available when | |
# ### analyzing the database. | |
# dartType: String? | |
--- | |
# yaml-language-server: $schema=https://go.fischerscode.com/serverpod-schema | |
class: ForeignKeyDefinition | |
fields: | |
### The name of the constraint. | |
constraintName: String | |
### The constraint column | |
column: String | |
### The table of the reference. | |
referenceTable: String | |
### The column of the reference in the [referenceTable]. | |
referenceColumn: String | |
### The action, when the referred row is updated. | |
onUpdate: ForeignKeyAction? | |
### The action, when the referred row is deleted. | |
onDelete: ForeignKeyAction? | |
--- | |
# yaml-language-server: $schema=https://go.fischerscode.com/serverpod-schema | |
enum: ForeignKeyAction | |
values: | |
- setNull | |
- setDefault | |
- restrict | |
- noAction | |
- cascade | |
--- | |
# yaml-language-server: $schema=https://go.fischerscode.com/serverpod-schema | |
### All the types, that are possible for columns. | |
### Contains all the values of [TypeDefinition.databaseType] | |
enum: ColumnType | |
values: | |
### Used for auto incrementing ids | |
- serial | |
### Dart type: [String] | |
- text | |
### Dart type: [bool] | |
- boolean | |
### Dart type: [int] | |
- integer | |
### Dart type: [double] | |
- double_precision | |
### Dart type: [DateTime] | |
- timestamp_without_time_zone | |
### Dart type: [ByteData] | |
- bytea | |
### Dart type: [Duration] | |
- bigint | |
### Dart type: [UuidValue] | |
- uuid | |
### Used for unknown types, that have never been | |
### used by Serverpod. | |
- unknown | |
--- | |
# yaml-language-server: $schema=https://go.fischerscode.com/serverpod-schema | |
### The definition of a (desired) index in the database. | |
class: IndexDefinition | |
fields: | |
### The user defined name of the index | |
indexName: String | |
### The fields, that are a part of this index. | |
fields: List<String> | |
### The type of the index | |
type: String | |
### Whether the index is unique. | |
isUnique: bool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment