mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 00:42:45 +08:00
By default, rails makes timestamp columns (`created_at` and `updated_at`) non-nullable, we also have some required core and plugins columns we wouldn't necessarily want to enforce in the intermediate DB schema. It'll be better to set the default values for these during import instead of enforcing these at the converter level. This change adds support for globally modifying a column’s `nullable` state, defaulting all `created_at` columns to be `nullable` while allowing for table level overrides. --------- Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
280 lines
7.6 KiB
JSON
Vendored
280 lines
7.6 KiB
JSON
Vendored
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"datatypes": {
|
|
"type": "string",
|
|
"enum": [
|
|
"blob",
|
|
"boolean",
|
|
"date",
|
|
"datetime",
|
|
"float",
|
|
"inet",
|
|
"integer",
|
|
"json",
|
|
"numeric",
|
|
"text"
|
|
]
|
|
}
|
|
},
|
|
"type": "object",
|
|
"required": [
|
|
"output",
|
|
"schema",
|
|
"plugins"
|
|
],
|
|
"properties": {
|
|
"output": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"schema_file": {
|
|
"type": "string"
|
|
},
|
|
"models_directory": {
|
|
"type": "string"
|
|
},
|
|
"models_namespace": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"schema_file",
|
|
"models_directory",
|
|
"models_namespace"
|
|
]
|
|
},
|
|
"schema": {
|
|
"type": "object",
|
|
"required": [
|
|
"tables",
|
|
"global"
|
|
],
|
|
"properties": {
|
|
"tables": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "object",
|
|
"properties": {
|
|
"columns": {
|
|
"type": "object",
|
|
"properties": {
|
|
"exclude": {
|
|
"type": "array",
|
|
"uniqueItems": true,
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"include": {
|
|
"type": "array",
|
|
"uniqueItems": true,
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"modify": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"datatype": {
|
|
"$ref": "#/$defs/datatypes"
|
|
},
|
|
"nullable": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"name"
|
|
],
|
|
"anyOf": [
|
|
{
|
|
"required": [
|
|
"datatype"
|
|
]
|
|
},
|
|
{
|
|
"required": [
|
|
"nullable"
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"add": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"datatype": {
|
|
"$ref": "#/$defs/datatypes"
|
|
},
|
|
"nullable": {
|
|
"type": "boolean"
|
|
},
|
|
"max_length": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"name",
|
|
"datatype"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"not": {
|
|
"required": [
|
|
"exclude",
|
|
"include"
|
|
]
|
|
}
|
|
},
|
|
"indexes": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"columns": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"uniqueItems": true
|
|
},
|
|
"unique": {
|
|
"type": "boolean"
|
|
},
|
|
"condition": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"name",
|
|
"columns"
|
|
]
|
|
}
|
|
},
|
|
"primary_key_column_names": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"uniqueItems": true
|
|
},
|
|
"copy_of": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
},
|
|
"global": {
|
|
"type": "object",
|
|
"properties": {
|
|
"columns": {
|
|
"properties": {
|
|
"modify": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"name_regex": {
|
|
"type": "string",
|
|
"format": "regex"
|
|
},
|
|
"datatype": {
|
|
"$ref": "#/$defs/datatypes"
|
|
},
|
|
"rename_to": {
|
|
"type": "string"
|
|
},
|
|
"nullable": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"anyOf": [
|
|
{
|
|
"required": [
|
|
"datatype"
|
|
]
|
|
},
|
|
{
|
|
"required": [
|
|
"rename_to"
|
|
]
|
|
},
|
|
{
|
|
"required": [
|
|
"nullable"
|
|
]
|
|
}
|
|
],
|
|
"oneOf": [
|
|
{
|
|
"required": [
|
|
"name"
|
|
]
|
|
},
|
|
{
|
|
"required": [
|
|
"name_regex"
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"exclude": {
|
|
"type": "array",
|
|
"uniqueItems": true,
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tables": {
|
|
"properties": {
|
|
"exclude": {
|
|
"type": "array",
|
|
"uniqueItems": true,
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"plugins": {
|
|
"type": "array",
|
|
"uniqueItems": true,
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
}
|