github.com/cayleygraph/cayley@v0.7.7/docs/migration.md (about) 1 # Migration 2 3 ## From Cayley 0.6.1 to 0.7.x 4 5 First you need to dump all the data from the database via v0.6.1: 6 7 ```bash 8 ./cayley-0.6 dump --db <backend> --dbpath <address> --dump_type pquads --dump ./data.pq.gz 9 ``` 10 11 or using config file: 12 13 ```bash 14 ./cayley-0.6 dump --config <config> --dump_type pquads --dump ./data.pq.gz 15 ``` 16 17 And load the data into new database via v0.7.x \(`pq` file extension is important\): 18 19 ```bash 20 ./cayley load --init -d <new-backend> -a <new-address> -i ./data.pq.gz 21 ``` 22 23 or using config file: 24 25 ```bash 26 ./cayley load --init -c <new-config> -i ./data.pq.gz 27 ``` 28 29 ### Dump via text format 30 31 An above guide uses Cayley-specific binary format to avoid encoding and parsing overhead and to compress output file better. 32 33 As an alternative, a standard nquads file format can be used to dump and load data \(note `nq` extension\): 34 35 ```bash 36 ./cayley-0.6 dump --config <config> --dump ./data.nq.gz 37 ./cayley load --init -c <new-config> -i ./data.nq.gz 38 ``` 39 40 ### Bolt, LevelDB, MongoDB 41 42 Cayley v0.7.0 is still able to read and write databases of these types in old format. It can be accessed by changing backend name from `bolt`/`leveldb`/`mongo` to `bolt1`/`leveldb1`/`mongo1`. Thus, you can use guide for moving data between different backends for v0.7.x \(see below\). 43 44 **Note:** support for old versions will be dropped starting from v0.7.1. 45 46 ### SQL 47 48 Data format for SQL between v0.6.1 and v0.7.x has not changed significantly. Database can be upgraded by executing the following SQL statements: 49 50 ```sql 51 ALTER TABLE quads DROP id; 52 ALTER TABLE nodes ADD refs INT DEFAULT 0 NOT NULL; 53 ALTER TABLE nodes ALTER COLUMN refs DROP DEFAULT; 54 UPDATE nodes SET refs = 55 (SELECT count(1) FROM quads WHERE subject_hash = nodes.hash) + 56 (SELECT count(1) FROM quads WHERE predicate_hash = nodes.hash) + 57 (SELECT count(1) FROM quads WHERE object_hash = nodes.hash) + 58 (SELECT count(1) FROM quads WHERE label_hash = nodes.hash); 59 ``` 60 61 ## From different backend \(Cayley 0.7+\) 62 63 First you need to dump all the data from old backend \(`pq` extension is important\): 64 65 ```bash 66 ./cayley dump -d <backend> -a <address> -o ./data.pq.gz 67 ``` 68 69 or using config file: 70 71 ```bash 72 ./cayley dump -c <config> -o ./data.pq.gz 73 ``` 74 75 And load the data into a new backend and/or database: 76 77 ```bash 78 ./cayley load --init -d <new-backend> -a <new-address> -i ./data.pq.gz 79 ``` 80 81 or using config file: 82 83 ```bash 84 ./cayley load --init -c <new-config> -i ./data.pq.gz 85 ``` 86 87 ### Dump via text format 88 89 An above guide uses Cayley-specific binary format to avoid encoding and parsing overhead and to compress output file better. 90 91 As an alternative, a standard nquads file format can be used to dump and load data \(note `nq` extension\): 92 93 ```bash 94 ./cayley dump -c <config> -o ./data.nq.gz 95 ./cayley load --init -c <new-config> -i ./data.nq.gz 96 ``` 97