···1181 return err
1182 })
11831184+ orm.RunMigration(conn, logger, "remove-profile-stats-column-constraint", func(tx *sql.Tx) error {
1185+ _, err := tx.Exec(`
1186+ -- create new table without the check constraint
1187+ create table profile_stats_new (
1188+ id integer primary key autoincrement,
1189+ did text not null,
1190+ kind text not null, -- no constraint this time
1191+ foreign key (did) references profile(did) on delete cascade
1192+ );
1193+1194+ -- copy data from old table
1195+ insert into profile_stats_new (id, did, kind)
1196+ select id, did, kind
1197+ from profile_stats;
1198+1199+ -- drop old table
1200+ drop table profile_stats;
1201+1202+ -- rename new table
1203+ alter table profile_stats_new rename to profile_stats;
1204+ `)
1205+ return err
1206+ })
1207+1208 return &DB{
1209 db,
1210 logger,
+3-1
appview/db/profile.go
···451 query = `select count(id) from repos where did = ?`
452 args = append(args, did)
453 case models.VanityStatStarCount:
454- query = `select count(id) from stars where did = ?`
455 args = append(args, did)
00456 }
457458 var result uint64
···451 query = `select count(id) from repos where did = ?`
452 args = append(args, did)
453 case models.VanityStatStarCount:
454+ query = `select count(id) from stars where subject_at like 'at://' || ? || '%'`
455 args = append(args, did)
456+ default:
457+ return 0, fmt.Errorf("invalid vanity stat kind: %s", stat)
458 }
459460 var result uint64
+1-1
appview/models/profile.go
···77 case VanityStatRepositoryCount:
78 return "Repositories"
79 case VanityStatStarCount:
80- return "Stars"
81 }
82 return ""
83}
···77 case VanityStatRepositoryCount:
78 return "Repositories"
79 case VanityStatStarCount:
80+ return "Stars Received"
81 }
82 return ""
83}