Update to migration to handle change of photoPath to identicon

This commit is contained in:
Samuel Hawksby-Robinson 2020-12-01 12:55:18 +00:00 committed by Andrea Maria Piana
parent 094ea2ce85
commit a087535274
3 changed files with 43 additions and 15 deletions

View File

@ -4,8 +4,8 @@
// 0001_accounts.up.sql (163B)
// 1605007189_identity_images.down.sql (29B)
// 1605007189_identity_images.up.sql (268B)
// 1606224181_drop_photo_path_from_accounts.down.sql (47B)
// 1606224181_drop_photo_path_from_accounts.up.sql (675B)
// 1606224181_drop_photo_path_from_accounts.down.sql (892B)
// 1606224181_drop_photo_path_from_accounts.up.sql (866B)
// doc.go (74B)
package migrations
@ -155,7 +155,7 @@ func _1605007189_identity_imagesUpSql() (*asset, error) {
return a, nil
}
var __1606224181_drop_photo_path_from_accountsDownSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x4c\x4e\xce\x2f\xcd\x2b\x29\xe6\x72\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\x28\xc8\xc8\x2f\xc9\x0f\x48\x2c\xc9\x50\x08\x71\x8d\x08\xb1\x06\x04\x00\x00\xff\xff\xc2\xe6\xd6\xb1\x2f\x00\x00\x00")
var __1606224181_drop_photo_path_from_accountsDownSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd4\x93\xc1\x6e\x9c\x30\x18\x84\xef\x3c\xc5\x1c\xdb\x95\x25\x1e\x60\x4f\x04\x9c\xc4\x2a\x0b\xc8\x98\x66\x73\x6a\x1c\xb0\x82\x15\xb0\x11\x6b\x54\xed\xdb\x57\x6b\x58\x76\x8b\xd4\xaa\xd7\x5e\xff\xf9\x7f\xcf\x68\x3e\x39\xdc\x21\xb6\xc3\x19\xae\x55\x90\x75\x6d\x27\xe3\x4e\x70\xf2\xbd\x53\xd0\xc6\x59\x48\x38\xd5\x0f\xf3\x84\x80\x1e\xe3\xb4\x4a\xa8\xdf\x7e\xd3\x8d\x32\x4e\xd7\xd6\xbc\xa1\xb6\xdd\xd4\x1b\x48\xd3\x80\x65\x77\x2b\x43\x6b\x9d\x2d\xa4\x6b\xd7\x95\x5d\x18\xc4\x9c\x46\x82\x42\xd0\x43\x91\xf3\x88\xbf\x42\x44\x0f\x29\x5d\xdd\x7f\xbc\xcb\xfa\x73\x1a\xbe\x04\x00\xf0\xa9\xce\x95\x6e\xf0\x3d\xe2\xf1\x73\xc4\x51\x70\x76\xb8\x5c\x7c\xa3\xaf\xc4\xeb\x46\xf6\x0a\x82\x1e\x05\xb2\x5c\x20\xab\xd2\x74\x9e\x77\xf6\x43\x1b\xa1\x7b\x75\x72\xb2\x1f\xf0\xc0\x9e\xc0\x32\x31\x6b\x6b\x28\x7f\x48\xae\x3e\xb5\x1c\x9b\x42\xea\x51\x9b\x0f\x2f\x04\x5f\xf1\xc2\xc4\x73\x5e\x09\xf0\xfc\x85\x25\xfb\x80\x65\x25\xe5\xe2\xf2\x50\xbe\x4d\x8b\x92\xa6\x34\x16\x4b\x5e\xe2\x73\x91\x4d\x0a\x82\xb5\x31\xb2\x35\x7c\xe4\xf9\x61\x7d\x73\x1f\x04\xe1\x0e\xc9\x68\x07\xdf\xa2\xed\x9a\x2d\x9a\x4b\xd1\xa3\xaa\x47\x25\x9d\xc2\x4f\xed\x5a\xc8\xae\x5b\x2a\x3e\x2d\x94\x58\xf6\xf4\x1b\xa3\x1b\x1c\xaf\xdc\xa1\xd9\x85\x41\xc2\xf3\x62\xc3\x61\xbf\x82\xf2\x63\xf6\xe8\x2b\xa6\x47\x56\x8a\xf2\x96\xe7\x3f\xc1\xf4\x6f\x7c\x56\xcb\xbf\xf3\x59\x98\xcf\x98\x84\x6e\xce\x98\x06\x82\xe6\xca\xeb\xf6\x61\xfe\xd0\xec\xf5\xfe\x57\x00\x00\x00\xff\xff\x72\x67\x20\xf9\x7c\x03\x00\x00")
func _1606224181_drop_photo_path_from_accountsDownSqlBytes() ([]byte, error) {
return bindataRead(
@ -170,12 +170,12 @@ func _1606224181_drop_photo_path_from_accountsDownSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.down.sql", size: 47, mode: os.FileMode(0644), modTime: time.Unix(1606258709, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xdc, 0x18, 0x37, 0x1a, 0x2, 0x2b, 0x46, 0x72, 0xe0, 0x25, 0xa6, 0x7c, 0x59, 0xa4, 0xde, 0x3a, 0x78, 0x30, 0x9a, 0xc6, 0xbf, 0x24, 0x96, 0xa6, 0x4, 0xa4, 0x73, 0x92, 0xc6, 0x18, 0xe4, 0xfc}}
info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.down.sql", size: 892, mode: os.FileMode(0644), modTime: time.Unix(1607535565, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x90, 0x24, 0x17, 0x7, 0x80, 0x93, 0x6f, 0x8d, 0x5d, 0xaa, 0x8c, 0x79, 0x15, 0x5d, 0xb3, 0x19, 0xd7, 0xd8, 0x39, 0xf9, 0x3a, 0x63, 0x8f, 0x81, 0x15, 0xb6, 0xd6, 0x9a, 0x37, 0xa8, 0x8e, 0x9b}}
return a, nil
}
var __1606224181_drop_photo_path_from_accountsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\xd2\xc1\xae\xa2\x30\x14\x06\xe0\x3d\x4f\xf1\x2f\x95\x90\xf0\x00\xae\x10\x3a\x4a\x06\x81\xd4\x32\xea\x6a\xac\xd0\x48\x23\xb4\x0d\x96\x4c\x7c\xfb\x89\x88\xde\x48\xee\x5d\xdc\xdc\xed\x81\xff\x9c\x9f\x2f\xf8\x2e\x42\x6d\x6e\xb0\xb5\x00\x2f\x4b\xdd\x2b\x7b\x85\xe5\xa7\x46\x40\x2a\xab\xc1\x61\x45\x6b\x1e\x13\x0f\x64\x1f\x26\x45\x44\x86\xb7\x8f\xa6\xd6\x56\xe7\xdc\xd6\x47\x94\xba\xe9\x5b\x05\xd7\x77\x42\x4a\x02\x46\xc0\xc8\x26\xcf\x68\x40\x0f\x60\xc1\x32\x21\xaf\xd5\x7f\x4f\xbc\xbc\xf4\x66\xe6\x00\xc0\x45\xdc\x0a\x59\xe1\x4f\x40\xc3\x75\x40\x91\xd3\x78\x73\x4f\xfc\x26\x07\x6f\x78\xae\x78\x2b\xc0\xc8\x9e\x21\xcd\x18\xd2\x22\x49\x1e\xf3\x46\x9f\xa5\x62\xb2\x15\x57\xcb\x5b\x83\x65\xbc\x42\x9c\x32\xef\xb9\xb3\xe4\x5d\x95\x73\xd9\x49\x75\x1e\xd2\xce\x1c\xbb\x98\xad\xb3\x82\x81\x66\xbb\x38\x5a\x38\x71\xba\x25\x94\xdd\x43\xd9\xb4\x19\xb6\x24\x21\x21\x1b\xbb\x79\x43\x07\x6f\x72\xd1\x9b\x5e\xf9\x45\xb3\xcd\x6b\xd1\xc2\x71\x7c\x17\x51\xa7\xcd\xc0\xa4\x9b\x6a\x0a\xcb\x55\x85\x4e\x94\x9d\xe0\x56\xe0\x9f\xb4\x35\x78\xd3\x8c\x86\xd7\xd1\x38\x4e\x57\x6f\xc2\xae\xef\x44\x34\xcb\x27\x9c\x8b\x97\xf7\xdb\x78\xf6\x9d\xf6\xf3\xcf\x3d\x7e\x0e\x31\x8a\x3e\x3c\x98\xac\x6e\xe8\x8d\x87\xea\x09\xf3\xf1\x5f\x7d\xf1\x71\xcf\xfc\xff\x00\x00\x00\xff\xff\x50\xd5\xcd\xce\xa3\x02\x00\x00")
var __1606224181_drop_photo_path_from_accountsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x93\xc1\x8e\x9b\x30\x18\x84\xef\x3c\xc5\x1c\x5b\x64\x89\x07\xc8\x89\x05\x77\xd7\x2a\x01\xe4\x35\xdd\xdd\x53\x71\xc0\x0a\x56\xc0\x46\xc4\xa8\xca\xdb\x57\x01\x42\x54\xd4\x56\xb9\xed\xf5\x1f\xff\xff\x8c\xe6\x93\x03\x1f\x91\xed\x2f\x70\x8d\x82\xac\x2a\x3b\x1a\x77\x86\x93\x87\x56\x41\x1b\x67\x21\xe1\x54\xd7\xcf\x13\x02\xfa\x1e\x25\x45\x4c\xa7\xd7\x65\xdf\x58\x67\x73\xe9\x9a\x12\xd2\xd4\x60\xe9\xac\x95\xba\x56\xc6\xe9\xca\x9a\x12\x95\x6d\xc7\xce\xc0\x0f\xbc\x88\xd3\x50\x50\x08\xba\xcf\x33\x1e\xf2\x0f\x88\xf0\x29\xa1\xab\xe5\xcf\x83\xac\x4e\x63\xff\xc5\x03\x80\x93\xba\x14\xba\xc6\x8f\x90\x47\x2f\x21\x47\xce\xd9\xfe\xba\xf1\x9d\x7e\x90\x49\x37\xb2\x53\x10\xf4\x5d\x20\xcd\x04\xd2\x22\x49\xe6\x79\x6b\x8f\xda\x08\xdd\xa9\xb3\x93\x5d\x8f\x27\xf6\x0c\x96\x8a\x59\x5b\x43\x4d\x8b\xe4\xe6\x53\xc9\xa1\xce\xa5\x1e\xb4\x39\x4e\x82\xf7\x15\x6f\x4c\xbc\x64\x85\x00\xcf\xde\x58\xbc\xf3\x58\xfa\x4a\xb9\xb8\x1e\xca\xb6\x69\xf1\x4a\x13\x1a\x89\x25\x2f\x99\x72\x91\x4d\x0a\x82\xb5\x26\xb2\x35\xfc\xc6\xb3\xfd\x7a\x73\xe7\x79\x81\x8f\x78\xb0\xfd\xd4\xae\x6d\xeb\x2d\x8f\x6b\xc9\x83\xaa\x06\x25\x9d\xc2\x2f\xed\x1a\xc8\xb6\x5d\x2a\x3e\x2f\x68\x58\xfa\xfc\x0f\x30\x93\x72\x47\xe3\x07\x5e\xcc\xb3\x7c\x83\x61\xb7\x72\xfa\x63\xfc\xf9\x58\xf0\x10\x97\xc7\x80\xac\x9e\xff\x07\xb2\x40\x9e\xb9\x08\x5d\x5f\x30\xf6\x04\xf5\x0d\xd0\xfd\x5b\xe0\xef\x5d\xde\xf6\x7f\x07\x00\x00\xff\xff\xc4\x05\x28\x49\x62\x03\x00\x00")
func _1606224181_drop_photo_path_from_accountsUpSqlBytes() ([]byte, error) {
return bindataRead(
@ -190,8 +190,8 @@ func _1606224181_drop_photo_path_from_accountsUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.up.sql", size: 675, mode: os.FileMode(0644), modTime: time.Unix(1606225159, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa7, 0x3a, 0x8e, 0xc7, 0x1a, 0xfc, 0x95, 0x2c, 0x3, 0xf4, 0x6b, 0xd0, 0x1f, 0xb6, 0xf9, 0x48, 0x99, 0xef, 0xcc, 0x97, 0xc4, 0x63, 0x94, 0x4, 0x82, 0xb8, 0xf5, 0xc2, 0xe0, 0x3c, 0x3e, 0x18}}
info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.up.sql", size: 866, mode: os.FileMode(0644), modTime: time.Unix(1607535565, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xff, 0x4c, 0x97, 0xee, 0xef, 0x82, 0xb8, 0x6c, 0x71, 0xbb, 0x50, 0x7b, 0xe6, 0xd9, 0x22, 0x31, 0x7c, 0x1a, 0xfe, 0x91, 0x28, 0xf6, 0x6, 0x36, 0xe, 0xb1, 0xf1, 0xc8, 0x25, 0xac, 0x7e, 0xd6}}
return a, nil
}

View File

@ -1,2 +1,23 @@
ALTER TABLE accounts
ADD COLUMN photoPath TEXT;
/* Copy the accounts table into a temp table, EXCLUDE the `identicon` column and INCLUDE the `photoPath` column */
CREATE TEMPORARY TABLE accounts_backup(
keyUid VARCHAR PRIMARY KEY,
name TEXT NOT NULL,
loginTimestamp BIG INT,
photoPath TEXT,
keycardPairing TEXT
) WITHOUT ROWID;
INSERT INTO accounts_backup SELECT keyUid, name, loginTimestamp, identicon, keycardPairing FROM accounts;
/* Drop the old accounts table and recreate with all columns EXCLUDING `identicon` and INCLUDING `photoPath` */
DROP TABLE accounts;
CREATE TABLE IF NOT EXISTS accounts (
keyUid VARCHAR PRIMARY KEY,
name TEXT NOT NULL,
loginTimestamp BIG INT,
photoPath TEXT,
keycardPairing TEXT
) WITHOUT ROWID;
INSERT INTO accounts SELECT keyUid, name, loginTimestamp, photoPath, keycardPairing FROM accounts_backup;
/* Tidy up, drop the temp table */
DROP TABLE accounts_backup;

View File

@ -1,16 +1,23 @@
/* Copy the accounts table into a temp table, EXCLUDE the `photoPath` column */
/* Copy the accounts table into a temp table, EXCLUDE the `photoPath` and INCLUDE `identicon` column */
CREATE TEMPORARY TABLE accounts_backup(
keyUid VARCHAR PRIMARY KEY,
name TEXT NOT NULL,
loginTimestamp BIG INT,
identicon TEXT,
keycardPairing TEXT
) WITHOUT ROWID;
INSERT INTO accounts_backup SELECT keyUid, name, loginTimestamp, keycardPairing FROM accounts;
INSERT INTO accounts_backup SELECT keyUid, name, loginTimestamp, photoPath, keycardPairing FROM accounts;
/* Drop the old accounts table and recreate with all columns EXCLUDING `photoPath` */
/* Drop the old accounts table and recreate with all columns EXCLUDING `photoPath` and INCLUDING `identicon`*/
DROP TABLE accounts;
CREATE TABLE accounts(keyUid, name, loginTimestamp, keycardPairing);
INSERT INTO accounts SELECT keyUid, name, loginTimestamp, keycardPairing FROM accounts_backup;
CREATE TABLE accounts(
keyUid VARCHAR PRIMARY KEY,
name TEXT NOT NULL,
loginTimestamp BIG INT,
identicon TEXT,
keycardPairing TEXT
) WITHOUT ROWID;
INSERT INTO accounts SELECT keyUid, name, loginTimestamp, identicon, keycardPairing FROM accounts_backup;
/* Tidy up, drop the temp table */
DROP TABLE accounts_backup;