-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #298 from smartdevicelink/hotfix/missing-permissions
Hotfix/missing permissions
- Loading branch information
Showing
9 changed files
with
318 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20220608172537-add-on-tbt-client-state-up.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20220608172537-add-on-tbt-client-state-down.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20220608173445-set-propriatarydate-up.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20220608173445-set-propriatarydate-down.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |
1 change: 1 addition & 0 deletions
1
migrations/sqls/20220608172537-add-on-tbt-client-state-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Leave blank. Avoid deleting permissions from functional groupings */ |
53 changes: 53 additions & 0 deletions
53
migrations/sqls/20220608172537-add-on-tbt-client-state-up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--Create OnTBTClientState for newest staging and production Navigation-1 groups. | ||
INSERT INTO function_group_hmi_levels(function_group_id, permission_name, hmi_level) | ||
SELECT id AS function_group_id, 'OnTBTClientState' AS permission_name, v.hmi_level::hmi_level AS hmi_level | ||
FROM view_function_group_info | ||
CROSS JOIN ( | ||
VALUES ('FULL'), ('LIMITED'), ('BACKGROUND') | ||
) AS v(hmi_level) | ||
WHERE property_name = 'Navigation-1' | ||
AND NOT EXISTS ( | ||
SELECT 1 | ||
FROM function_group_hmi_levels | ||
WHERE function_group_id = id | ||
AND permission_name = 'OnTBTClientState' | ||
); | ||
|
||
|
||
-- RECREATE AFFECTED VIEWS -- | ||
CREATE OR REPLACE VIEW view_function_group_info AS | ||
SELECT function_group_info.* | ||
FROM ( | ||
SELECT property_name, status, max(id) AS id | ||
FROM function_group_info | ||
GROUP BY property_name, status | ||
) AS vfgi | ||
INNER JOIN function_group_info ON vfgi.id = function_group_info.id; | ||
|
||
CREATE OR REPLACE VIEW view_mapped_permissions AS | ||
SELECT function_group_id AS id, permission_name AS name, status, property_name, is_deleted | ||
FROM view_function_group_info | ||
INNER JOIN function_group_hmi_levels | ||
ON view_function_group_info.id = function_group_hmi_levels.function_group_id | ||
WHERE is_deleted=false | ||
UNION | ||
SELECT function_group_id AS id, parameter AS name, status, property_name, is_deleted | ||
FROM view_function_group_info | ||
INNER JOIN function_group_parameters | ||
ON view_function_group_info.id = function_group_parameters.function_group_id | ||
WHERE is_deleted=false; | ||
|
||
CREATE OR REPLACE VIEW view_mapped_permissions_staging AS | ||
SELECT view_mapped_permissions.* | ||
FROM view_mapped_permissions | ||
INNER JOIN ( | ||
SELECT max(id) AS id, property_name | ||
FROM view_function_group_info | ||
GROUP BY property_name | ||
) fgi | ||
ON view_mapped_permissions.id = fgi.id; | ||
|
||
CREATE OR REPLACE VIEW view_mapped_permissions_production AS | ||
SELECT view_mapped_permissions.* FROM view_mapped_permissions | ||
WHERE status = 'PRODUCTION'; | ||
-- END VIEW RECREATION -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
UPDATE function_group_info | ||
SET is_proprietary_group = 'false' | ||
WHERE property_name IN ('PropriataryData-1','PropriataryData-2','ProprietaryData-3'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
UPDATE function_group_info | ||
SET is_proprietary_group = 'true' | ||
WHERE property_name IN ('PropriataryData-1','PropriataryData-2','ProprietaryData-3'); |
Oops, something went wrong.