mirror of
https://github.com/status-im/status-go.git
synced 2025-02-16 08:50:09 +00:00
fix: profile social links, position
column addded
This commit is contained in:
parent
cff7d2f693
commit
a11cbb2f30
@ -65,7 +65,7 @@
|
||||
// 1685041348_settings_table_add_latest_derived_path_column.up.sql (115B)
|
||||
// 1685440989_update_color_id_accounts.up.sql (918B)
|
||||
// 1685463947_add_to_asset_to_multitransaction.up.sql (61B)
|
||||
// 1685880973_add_profile_links_settings_table.up.sql (1.254kB)
|
||||
// 1685880973_add_profile_links_settings_table.up.sql (1.656kB)
|
||||
// doc.go (74B)
|
||||
|
||||
package migrations
|
||||
@ -1435,7 +1435,7 @@ func _1685463947_add_to_asset_to_multitransactionUpSql() (*asset, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var __1685880973_add_profile_links_settings_tableUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x93\xdd\x6e\xdb\x46\x10\x85\xef\xf9\x14\xa7\xee\x45\x45\xc0\x8c\xec\x26\x46\x8a\x06\x2e\xc0\x4a\x74\x4d\x84\x96\x0c\x8a\x6e\x9b\x2b\x65\xbd\x1c\x91\x0b\x2f\x77\x95\xdd\xa1\x59\xbf\x7d\xc1\x1f\xb9\x16\xa0\x16\xbd\x5b\x62\xce\xfc\x7d\x67\x18\x45\x58\x38\x12\x4c\x30\xd4\x81\xc5\xa3\x26\x74\x35\x39\x42\x47\xe8\x94\xd6\xf0\x6c\x1d\x61\xef\xec\x4e\x69\x82\xb7\x52\x09\x0d\xad\xcc\x93\x3f\x0f\xa2\x08\x62\xc7\xe4\x50\x2a\x2f\x5b\xef\x95\x35\xa8\x99\xf7\xfe\xe7\xf9\xbc\x52\x5c\xb7\x8f\xef\xa4\x6d\xe6\x9e\x05\xb7\x3e\x52\xaf\xaf\xca\xce\xf7\xad\xd6\xf3\xf7\x57\x57\x3f\x7e\xaf\xbc\x6f\x49\xda\xa6\x21\xc3\xd1\xe5\xd5\xc7\xf7\x3f\x5d\x7e\xbc\xf8\xf0\xa1\x2f\xde\x11\x4a\x92\xaa\xa4\x12\x6c\xe1\x68\xaf\x85\x24\x70\x4d\x20\xc3\xca\x11\xca\xc7\x69\x66\x69\x0d\x93\x61\x58\x03\x7a\x26\xf7\x02\x59\x0b\x53\x11\x66\x8f\x24\x45\xeb\x09\x76\x07\xae\x05\x63\x6f\xbd\xe2\x7e\x4e\x69\x75\xdb\x18\x28\x0f\x63\x19\x86\xa8\xa4\x32\x0c\x16\x79\x12\x17\x09\x8a\xf8\xd7\x2c\x41\x7a\x83\xd5\xba\x40\xf2\x67\xba\x29\x36\x07\x04\xdb\x11\xc1\x76\x40\x80\x59\x00\x30\xfd\xc5\xf8\x3d\xce\x17\xb7\x71\x3e\x24\xac\x1e\xb2\x0c\x8b\xdb\x64\xf1\x19\x33\x4d\xa6\xe2\x7a\xc6\x4e\x35\xb3\x5e\x18\x86\xf8\x05\x17\xe1\x79\x00\xb4\x4e\xff\xaf\xb4\xd6\xe9\x37\x59\xf7\x79\x7a\x17\xe7\x5f\xf0\x39\xf9\x82\xa1\xe2\x79\x5f\x28\x0c\xc2\x4f\x41\x70\xec\xe6\xb4\x21\x5b\x3c\x11\xed\x21\xb5\x95\x4f\x23\x07\x82\x16\x9e\x0f\x8c\xec\xee\xa4\xbd\x98\x79\x65\xe4\x3f\x68\x95\x3f\x38\x50\x42\x68\x0d\x67\x3b\xf8\x5a\xb8\xd1\x10\x2f\x1a\x9a\x5a\x3c\x0b\xdd\x52\x18\xc4\x59\x91\xe4\x13\x49\x4f\xcc\xca\x54\x7e\xeb\x5f\x8c\xdc\x8e\xb2\x78\xb9\xc4\x62\x9d\x3d\xdc\xad\x70\x84\x34\x5d\x15\xc9\x6f\xc9\x1b\x24\xcb\xe4\x26\x7e\xc8\x0a\x5c\x8c\x1b\xa6\xc6\x93\x63\x28\xc3\x16\x5f\x4f\x99\xf2\x75\xbc\x89\x20\x5d\x6d\x92\xbc\xe8\xeb\xad\xff\xc5\xbc\x37\xf8\x80\x4d\x92\x25\x8b\x62\xd8\x7d\x3b\x06\x86\x67\xeb\x74\x00\xdc\xe4\xeb\xbb\xa3\x31\xb7\x87\x95\x02\xe0\x8f\xdb\x24\x4f\x5e\xd5\xf8\xee\x1a\x67\x67\xe3\xac\x37\xce\x36\xf0\xb6\x21\x38\x12\xde\x9a\x01\xd5\xce\x6a\x6d\x3b\x65\x2a\xf8\x6f\x1a\xa5\x25\x6f\x7e\x60\x74\xd6\x3d\x81\x6b\x67\xdb\xaa\xc6\xeb\x7f\x82\x46\x55\x4e\xf4\x07\xeb\xcf\x21\x34\xd7\x43\xb8\xaf\xf2\xad\xed\xcf\x5c\x79\x48\xeb\x1c\x49\x7e\xd7\xf7\x8b\x22\x6c\x88\x87\xf8\x08\x79\x67\xdd\x49\x73\x7b\xf1\xc3\xfd\xb2\xbf\xf5\x13\xde\xf4\xd1\x1e\x48\x31\x3e\x70\x6c\xd0\x35\x66\x13\xab\x37\xe2\xff\x44\x34\x29\x4e\x71\x3a\xc4\xb2\xf4\x2e\x2d\x70\x19\x8e\xdf\xa3\xd2\xbf\x18\xae\x89\x95\xdc\xaa\x12\xd7\x38\x53\xe5\x84\x75\xe9\xec\x1e\x56\x97\x93\xd1\xcb\x7c\x7d\x7f\x38\xb4\x53\xfd\x3f\xfd\x1d\x00\x00\xff\xff\x16\x8e\x9a\x75\xe6\x04\x00\x00")
|
||||
var __1685880973_add_profile_links_settings_tableUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x54\x5d\x6f\xe3\x36\x10\x7c\xd7\xaf\x98\x5e\x1f\x6a\x03\xf6\x39\xe9\x5d\x70\x45\x8b\x14\x70\x6d\xa6\x11\xce\x1f\x81\x2c\xb7\xbd\x27\x1f\x23\xad\x2d\x22\x14\xe9\x23\x57\xe7\xe6\xdf\x17\x94\x6c\xc5\x46\x95\x6b\xdf\x68\xef\x2c\x77\x76\x66\xa8\xe1\x10\x13\x47\x92\x09\x86\x0e\x60\xf9\xa8\x09\x87\x82\x1c\xe1\x40\x38\x28\xad\xe1\xd9\x3a\xc2\xde\xd9\xad\xd2\x04\x6f\x33\x25\x35\xb4\x32\x4f\x7e\x10\x0d\x87\x90\x5b\x26\x87\x5c\xf9\xac\xf2\x5e\x59\x83\x82\x79\xef\x7f\x1e\x8d\x76\x8a\x8b\xea\xf1\x6d\x66\xcb\x91\x67\xc9\x95\x1f\xaa\xf6\xb4\xb3\xa3\x7d\xa5\xf5\xe8\xdd\xcd\xcd\x8f\xdf\x2b\xef\x2b\xca\x6c\x59\x92\xe1\xe1\xf5\xcd\x87\x77\x3f\x5d\x7f\xb8\x7a\xff\x3e\x5c\x7e\x20\xe4\x94\xa9\x9c\x72\xb0\x85\xa3\xbd\x96\x19\x81\x0b\x02\x19\x56\x8e\x90\x3f\x1e\x39\x67\xd6\x30\x19\x86\x35\xa0\xaf\xe4\x9e\x91\x15\xd2\xec\x08\xbd\x47\xca\x64\xe5\x09\x76\x0b\x2e\x24\x63\x6f\xbd\xe2\xc0\x33\xb3\xba\x2a\x0d\x94\x87\xb1\x0c\x43\x94\x53\xde\x8f\x26\x89\x18\xa7\x02\xe9\xf8\xb7\x99\x40\x7c\x87\xc5\x32\x85\xf8\x2b\x5e\xa5\xab\x93\x04\x9b\x46\x82\x4d\x2d\x01\x7a\x11\xc0\xf4\x37\xe3\x8f\x71\x32\xb9\x1f\x27\x75\xc3\x62\x3d\x9b\x61\x72\x2f\x26\x1f\xd1\xd3\x64\x76\x5c\xf4\xd8\xa9\xb2\x17\x80\xfd\x3e\x7e\xc5\x55\x7f\x10\x01\x95\xd3\xff\xab\xad\x72\xfa\xac\xab\x5d\x20\x5e\xa4\x98\x8a\xbb\xf1\x7a\x96\xe2\x2a\x54\x1e\x92\x78\x3e\x4e\x3e\xe1\xa3\xf8\x84\x7a\xd6\x20\x8c\xe8\x47\xfd\x5f\xa2\xe8\xd2\xe7\xe3\xee\x6c\xf1\x44\xb4\x47\xa6\x6d\xf6\xd4\x28\x44\xd0\xd2\xf3\x49\x3d\xbb\xed\x34\x1e\x3d\xaf\x4c\xf6\x22\xba\xf2\x27\x6f\x72\x48\xad\xe1\xec\x01\xbe\x90\xae\xb1\xca\xcb\x92\x8e\x23\xbe\x4a\x5d\x51\x3f\x1a\xcf\x52\x91\x1c\x35\xf6\xc4\xac\xcc\xce\x6f\xfc\xb3\xc9\x36\x0d\x6c\x3c\x9d\x62\xb2\x9c\xad\xe7\x0b\x5c\x88\x1d\x2f\x52\xf1\xbb\x38\x13\xab\x5d\xff\x62\x43\xa6\x72\x7f\x8c\x05\x5b\xec\xc8\x90\x0b\x7f\xcb\x17\xe9\xb6\xd6\x05\x92\xbe\xb5\x5b\xcc\x1f\x96\x49\xd0\xae\x21\x15\x6e\xb8\xf0\x79\x73\xa2\x59\x1b\xae\xf2\x96\xca\xb9\xe6\xe3\x75\xba\x8c\x17\x93\x44\xcc\xc5\x22\x1d\xbc\x16\x8c\xd7\x9c\x6f\x6d\xb2\xfb\xe7\xc0\xfb\x65\x8b\x28\x5e\xac\x44\x92\x86\x99\xcb\x6f\x52\x3b\xf3\x1c\x58\x89\x99\x98\xa4\xb5\x61\x9b\xa6\x50\x1f\x2b\xa7\x23\xe0\x2e\x59\xce\xd1\x79\x4b\x04\xfc\x79\x2f\x12\xd1\xa2\xf1\xdd\x2d\xde\xbc\x69\xb8\xc5\xc6\x93\x63\x28\xc3\x16\x9f\xbb\xde\xc3\xe7\x0e\xc6\x5d\xb8\x17\x7e\x2d\xe7\x01\x54\x7e\x62\xf6\xfa\x92\x0d\x8f\x3b\x67\x4b\x78\x5b\x12\x1c\x49\x6f\x4d\x9d\xb3\xad\xd5\xda\x1e\x94\xd9\xc1\x7f\xd1\xc8\x2d\x79\xf3\x03\xe3\x60\xdd\x13\xb8\x70\xb6\xda\x15\x68\x3f\x3f\x28\xd5\xce\xc9\x90\x05\x3f\x80\xd4\x5c\xd4\xe5\x70\xcb\x97\x2a\x7c\x3d\x94\x47\x66\x9d\xa3\x8c\xdf\x86\x79\xc3\x21\x56\xc4\x75\xbd\x49\x68\x08\x50\xd7\xcb\x08\xe0\xf5\xc3\x34\x64\xaa\x23\xd8\xa1\x1a\x16\x4f\x9b\x03\x2e\xd3\x7d\x8b\xde\x51\x93\x33\xf0\x37\xad\x3a\x22\xba\xfc\x3a\xd5\x66\xf1\x3c\x4e\x71\xdd\x6f\x7e\x37\x48\xff\x6c\xb8\x20\x56\xd9\x46\xe5\xb8\xc5\x1b\x95\x1f\xed\x9d\x3a\xbb\x3f\xcf\xdd\x34\x59\x3e\xfc\xe7\x8b\x38\x6b\xb5\x3a\xff\x77\x67\x77\xd3\x3f\x01\x00\x00\xff\xff\x31\x2f\xbb\x07\x78\x06\x00\x00")
|
||||
|
||||
func _1685880973_add_profile_links_settings_tableUpSqlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
@ -1450,8 +1450,8 @@ func _1685880973_add_profile_links_settings_tableUpSql() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1685880973_add_profile_links_settings_table.up.sql", size: 1254, mode: os.FileMode(0644), modTime: time.Unix(1685979377, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xcc, 0xa4, 0xea, 0x41, 0x4e, 0xf, 0xea, 0x99, 0x9c, 0x8c, 0xe4, 0x22, 0xb7, 0x64, 0x8c, 0x9a, 0xac, 0x6, 0xc3, 0xbc, 0x4a, 0x40, 0xbe, 0x79, 0x73, 0x30, 0x29, 0x33, 0x88, 0x6a, 0x81, 0xf7}}
|
||||
info := bindataFileInfo{name: "1685880973_add_profile_links_settings_table.up.sql", size: 1656, mode: os.FileMode(0644), modTime: time.Unix(1685979463, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x13, 0x23, 0x7b, 0x1e, 0x82, 0x61, 0xcc, 0x76, 0xd6, 0xc7, 0x42, 0x6e, 0x69, 0x21, 0x1b, 0xfd, 0x7d, 0xda, 0xd7, 0xb7, 0xc7, 0xd3, 0x22, 0x63, 0xfe, 0xc6, 0xd3, 0xdf, 0xc8, 0x5f, 0x50, 0xcc}}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,31 @@
|
||||
CREATE TABLE IF NOT EXISTS profile_social_links (
|
||||
text VARCHAR NOT NULL CHECK (length(trim(text)) > 0),
|
||||
url VARCHAR NOT NULL CHECK (length(trim(url)) > 0),
|
||||
position INT DEFAULT 0,
|
||||
PRIMARY KEY (text, url)
|
||||
);
|
||||
|
||||
-- Create new column to keep clock of the last change of profile social links (since content is replaced all row share the same clock value)
|
||||
ALTER TABLE settings_sync_clock ADD COLUMN social_links INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
-- Insert into `profile_social_links` table
|
||||
INSERT INTO profile_social_links (text, url)
|
||||
-- Create temp table to generate a position for rows
|
||||
CREATE TEMPORARY TABLE temp_social_links_settings (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
text VARCHAR NOT NULL,
|
||||
url VARCHAR NOT NULL
|
||||
);
|
||||
|
||||
-- Copy to temp table
|
||||
INSERT INTO temp_social_links_settings (text, url)
|
||||
SELECT link_text, link_url
|
||||
FROM social_links_settings
|
||||
WHERE link_url != "";
|
||||
|
||||
-- Insert into `profile_social_links` table
|
||||
INSERT INTO profile_social_links
|
||||
SELECT text, url, id
|
||||
FROM temp_social_links_settings;
|
||||
|
||||
-- From some reason the following sql doesn't work through status-go migrations, although the query is correct.
|
||||
-- -- Set the clock for profile social links
|
||||
-- UPDATE settings_sync_clock
|
||||
@ -26,5 +39,8 @@ INSERT INTO profile_social_links (text, url)
|
||||
-- LIMIT 1)
|
||||
-- WHERE synthetic_id = "id";
|
||||
|
||||
-- Drop temp table
|
||||
DROP TABLE temp_social_links_settings;
|
||||
|
||||
-- Drop old table
|
||||
DROP TABLE social_links_settings;
|
@ -41,7 +41,7 @@ func (s *SocialLinksSettings) getSocialLinks(tx *sql.Tx) (identity.SocialLinks,
|
||||
rows *sql.Rows
|
||||
err error
|
||||
)
|
||||
query := "SELECT * FROM profile_social_links"
|
||||
query := "SELECT text, url FROM profile_social_links ORDER BY position ASC"
|
||||
|
||||
if tx == nil {
|
||||
rows, err = s.db.Query(query)
|
||||
@ -112,19 +112,20 @@ func (s *SocialLinksSettings) AddOrReplaceSocialLinksIfNewer(links identity.Soci
|
||||
}
|
||||
}
|
||||
|
||||
stmt, err := tx.Prepare("INSERT INTO profile_social_links (text, url) VALUES (?, ?)")
|
||||
stmt, err := tx.Prepare("INSERT INTO profile_social_links (text, url, position) VALUES (?, ?, ?)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
for _, link := range links {
|
||||
for position, link := range links {
|
||||
if link == nil {
|
||||
return ErrNilSocialLinkProvided
|
||||
}
|
||||
_, err = stmt.Exec(
|
||||
link.Text,
|
||||
link.URL,
|
||||
position,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -111,7 +111,7 @@ func TestProfileSocialLinksUpdate(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
clock = 2
|
||||
// test sociial link update
|
||||
// test social link update
|
||||
updateLinkAtIndex := 2
|
||||
profileSocialLinks[updateLinkAtIndex].Text = identity.GithubID
|
||||
profileSocialLinks[updateLinkAtIndex].URL = "https://github.com/status-im"
|
||||
|
Loading…
x
Reference in New Issue
Block a user