8 changed files with 46 additions and 7 deletions
@ -0,0 +1,29 @@ |
|||
-- |
|||
-- Copyright © 2016-2023 The Thingsboard Authors |
|||
-- |
|||
-- Licensed under the Apache License, Version 2.0 (the "License"); |
|||
-- you may not use this file except in compliance with the License. |
|||
-- You may obtain a copy of the License at |
|||
-- |
|||
-- http://www.apache.org/licenses/LICENSE-2.0 |
|||
-- |
|||
-- Unless required by applicable law or agreed to in writing, software |
|||
-- distributed under the License is distributed on an "AS IS" BASIS, |
|||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
-- See the License for the specific language governing permissions and |
|||
-- limitations under the License. |
|||
-- |
|||
|
|||
DO |
|||
$$ |
|||
BEGIN |
|||
IF NOT EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name = 'user_settings' AND column_name = 'settings' AND data_type = 'jsonb') THEN |
|||
ALTER TABLE user_settings RENAME COLUMN settings to old_settings; |
|||
ALTER TABLE user_settings ADD COLUMN settings jsonb; |
|||
UPDATE user_settings SET settings = old_settings::jsonb WHERE old_settings IS NOT NULL; |
|||
ALTER TABLE user_settings DROP COLUMN old_settings; |
|||
END IF; |
|||
END; |
|||
$$; |
|||
|
|||
CREATE INDEX IF NOT EXISTS idx_user_settings_mobile_fcm_token ON user_settings ((settings ->> 'fcmToken')) WHERE type = 'MOBILE'; |
|||
Loading…
Reference in new issue