Closed sirex closed 2 months ago
Regarding text
type, currently there are a lot of cases like this:
d | r | b | m | property | type | ref
dataset1 | |
| | | Country | | id
| | | | id | integer |
| | | | name_lt | string |
| | | | name_en | string |
Because for a long time, text
type was not supported. Now since text
is introduced, there will be a lot of changes, for manifest table above, into the following:
d | r | b | m | property | type | ref
dataset1 | |
| | | Country | | id
| | | | id | integer |
| | | | name@lt | string |
| | | | name@en | string |
In order to migrate this change we need to do:
name
.name_lt
and name_en
into name[lt]
and name[en]
.name_lt
and name_en
into __name_lt
and __name_en
.When migrating from
d | r | b | m | property | type | ref | level
dataset1 | | |
| | | Country | | id | 4
| | | | id | integer | | 4
| | | City | | id | 4
| | | | id | integer | | 4
| | | | country | integer | | 2
to
d | r | b | m | property | type | ref | level
dataset1 | | |
| | | Country | | id | 4
| | | | id | integer | | 4
| | | City | | id | 4
| | | | id | integer | | 4
| | | | country | ref | Country | 4
We assume, that City.country
connects to Country
via primary key Country.id
, thus migrations should be done as follows:
City
with Country
on City.country = Country.id
if there are reference from City.country
that does not exists in Country.id
, then migration should be abborted, providing clear error message with few samples of City.country
, that does not exists in Country.id
.country._id
.Country._id
into City.country._id
by joining City
and Country
using City.country = Country.id
.City.country._id
.City.country
into City.__country
.
Currently
spinta migrate
does not support type casting.For example if we previously had
string
type, and then type was changed tointeger
, when runningspinta migrate
we will get:Same applies to other cases, when type changes.
List of type conversions we need to support:
string
->integer
,number
,boolean
- this might fail if string contains non numeric symbols, bet if string has only digits it should work.integer
,number
,boolean
->string
string
->text
text
->string
- converts into multiple columns with language suffix for examplename_lt
.string
->date
,datetime
date
,datetime
->string
- converts dates to ISO date formatestring
->geometry
- convert WKT to geometry type, expects string to be WKTgeometry(form, crs)
->geometry(form, crs)
- convert geometry if form or crs changesref level:3
->ref level:4
- convert from reference by local id to reference by _idref level:4
->ref level:3
- convert ref by _id to ref by local idstring
,integer
->ref level:3
,ref level:4
- convert primitive types to referencesref level:3
,ref level:4
->string
,integer
- convert references back to primitive typesWhen converting references, here is an example, how this was done manually:
Example with geometry SRID change: