Skip to content

Commit

Permalink
Insert array in migration, rather than create a new (nested) array
Browse files Browse the repository at this point in the history
Before migrations:

	"widgets": [
	  { "n": "pages", "s": { "limit_pages": 10, "limit_refs": 10 } },
	  [..]
	  { "n": "locations", "s": { "key": "", "limit": 6 } }
	]

After migrations it was:

	"widgets": [
	  [
		{ "n": "pages", "s": { "limit_pages": 10, "limit_refs": 10 } },
		[..]
		{ "n": "locations", "s": { "key": "", "limit": 6 } }
	  ],
	  { "n": "languages" }
	]

So that's an extra level, since json_array() creates a new array, rather
than merging two arrays.

#569 (comment)
  • Loading branch information
arp242 committed Feb 16, 2022
1 parent d869938 commit c4e25f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions db/migrate/2021-12-02-2-language-enable-sqlite.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
update sites set
settings = json_replace(settings, '$.collect', json_extract(settings, '$.collect') | 64),
user_defaults = json_replace(user_defaults, '$.widgets', json_array(json_extract(user_defaults, '$.widgets'), json('{"n":"languages"}')));
user_defaults = json_replace(user_defaults, '$.widgets', json_insert(json_extract(user_defaults, '$.widgets'), '$[#]', json('{"n":"languages"}')));
update users set
settings = json_replace(settings, '$.widgets', json_array(json_extract(settings, '$.widgets'), json('{"n":"languages"}')));
settings = json_replace(settings, '$.widgets', json_insert(json_extract(settings, '$.widgets'), '$[#]', json('{"n":"languages"}')));

0 comments on commit c4e25f0

Please sign in to comment.