T
Twenty6d ago
Raph

I think I may have suffered a migration regression for "phones". Migration from v.0.33 to v0.34

Hey All, I went through the path of updating from v.0.33 to v.0.34 and I'm experiencing some regression on the DB in the form of phones. Can somsone point me to the migrations files for the new phone structure and the migrations that were supposed to take place? Although I'll keep digging, I haven't been able to locate the migrations that changes the phones format and country code. I'm currently getting the following error and it's broken my FE:
error: error: column person.phonesPrimaryPhoneNumber does not exist
error: error: column person.phonesPrimaryPhoneNumber does not exist
I can certainy create the column, but I'm also missing the others like phone.phonesPrimaryPhoeCountryCode. All of these columns are missing from my person schema. Super weird, and kinda scary.
37 Replies
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
Hi, did you check the files in packages/twenty-server/src/database/commands/upgrade-version/0-34?
Raph
RaphOP6d ago
Hi, @ɃØĦɆᵾS - Yes, I'm actually in there poking around now.
Raph
RaphOP6d ago
GitHub
Build software better, together
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
From An unknown user
From An unknown user
From An unknown user
Raph
RaphOP6d ago
Seems like the DB has dropped all of our phone numbers and reverted back to the old phone format. 😬 So now I'm just trying to dig that back up. any idea what version it was when the phone format changed? v.0.32?
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
That's weird, what do you get if you run select column_name from information_schema.columns where table_schema='{your_workspace}' and table_name='person';?
Raph
RaphOP6d ago
super weird. lemme check
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
Just replace {your_workspace} 😉
Raph
RaphOP6d ago
yep Just doing some double checking, but nothing returns.
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
This query returns nothing?
Raph
RaphOP6d ago
nope
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
🤔
Raph
RaphOP6d ago
Successfully run. Total query runtime: 247 msec.
0 rows affected.
Successfully run. Total query runtime: 247 msec.
0 rows affected.
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
So basically it shows that person table in your workspace is completely empty
Raph
RaphOP6d ago
oh! hold on workspace_{workspace_id} It returns 30 rows
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
Oh, it should looks something like this select column_name from information_schema.columns where table_schema='workspace_1wgvd1injqtife6y4rvfbu3h5' and table_name='person'; Neat, could you send the result of your query?
Raph
RaphOP6d ago
No description
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
From what I can see, some records are cut You don't have to worry you'll leak something, this query returns names of all columns of specified table
Raph
RaphOP6d ago
I think we're missing those other phone columns.
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
And also, you have some columns which I don't see on my end like lifecycleStage
Raph
RaphOP6d ago
that might be a custom field.
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
Let me check it
Raph
RaphOP6d ago
Yes, it's custom.
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
You're right, I checked it on my end, when added new custom field, new column appeared
Raph
RaphOP6d ago
No description
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
For reference, here are all columns, which should be in your database (assuming all fields created by default when setting up app are in place)
column_name
---------------------------------
id
nameFirstName
nameLastName
emailsPrimaryEmail
emailsAdditionalEmails
linkedinLinkPrimaryLinkLabel
linkedinLinkPrimaryLinkUrl
linkedinLinkSecondaryLinks
xLinkPrimaryLinkLabel
xLinkPrimaryLinkUrl
xLinkSecondaryLinks
jobTitle
phonesPrimaryPhoneNumber
phonesPrimaryPhoneCountryCode
phonesPrimaryPhoneCallingCode
phonesAdditionalPhones
city
avatarUrl
position
createdBySource
createdByWorkspaceMemberId
createdByName
searchVector
createdAt
updatedAt
deletedAt
companyId
intro
whatsappPrimaryPhoneNumber
whatsappPrimaryPhoneCountryCode
whatsappPrimaryPhoneCallingCode
whatsappAdditionalPhones
workPreference
performanceRating
column_name
---------------------------------
id
nameFirstName
nameLastName
emailsPrimaryEmail
emailsAdditionalEmails
linkedinLinkPrimaryLinkLabel
linkedinLinkPrimaryLinkUrl
linkedinLinkSecondaryLinks
xLinkPrimaryLinkLabel
xLinkPrimaryLinkUrl
xLinkSecondaryLinks
jobTitle
phonesPrimaryPhoneNumber
phonesPrimaryPhoneCountryCode
phonesPrimaryPhoneCallingCode
phonesAdditionalPhones
city
avatarUrl
position
createdBySource
createdByWorkspaceMemberId
createdByName
searchVector
createdAt
updatedAt
deletedAt
companyId
intro
whatsappPrimaryPhoneNumber
whatsappPrimaryPhoneCountryCode
whatsappPrimaryPhoneCallingCode
whatsappAdditionalPhones
workPreference
performanceRating
Raph
RaphOP6d ago
Awesome! Thank you. Any chance you can produce a schema export script? Although, I just don't want to mess with the ORM.. Are all of the above standard fields?
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
No, these are all default fields, which include both standard and custom fields
No description
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
And about schema script, first of all, I'm not entirely sure if you should have all these columns as I'm on canary version, and second, messing with database is quite risky
Raph
RaphOP6d ago
100% I'm going to revert back and see what happens. Is there a command to check the state of the schema? When I run the migrations command it returns with no migrations to be made.
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
I'll probably add some disclaimer in docs for upgrading workspace to simply backup workspace before running upgrade script because almost every new release there are some bugs related to migration
Raph
RaphOP6d ago
Ha! That should be inherent .
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
As far as I know, sadly no
Raph
RaphOP6d ago
I did do a backup. I just figured the ORM would kick and scream on startup that the schema wasn't accurate. It looks like phones became a problem prior to my 33.7 so I guess we've been operating with this issue for quite some time.
Raph
RaphOP6d ago
I take that back, but the other columns you have are certainly missing from mine:
No description
Raph
RaphOP6d ago
This is from an older backup of 33.7 Ok, back to the most recent state of Twenty. This is what I did to get the app back up. (Highly not recommended to mess with the DB manually):
ALTER TABLE IF EXISTS workspace_XXXXXXXXXXXXXX.person
ADD COLUMN "phonesPrimaryPhoneNumber" text COLLATE pg_catalog."default" DEFAULT ''::text,
"phonesPrimaryPhoneCountryCode" text COLLATE pg_catalog."default" DEFAULT ''::text,
"phonesAdditionalPhones" jsonb;
ALTER TABLE IF EXISTS workspace_XXXXXXXXXXXXXX.person
ADD COLUMN "phonesPrimaryPhoneNumber" text COLLATE pg_catalog."default" DEFAULT ''::text,
"phonesPrimaryPhoneCountryCode" text COLLATE pg_catalog."default" DEFAULT ''::text,
"phonesAdditionalPhones" jsonb;
ɃØĦɆᵾS
ɃØĦɆᵾS6d ago
So is Twenty working right now? I'm sorry for delay
Raph
RaphOP4d ago
yes, all good. I'm just watching the logs looking for exceptions/etc I did run a REINDEX here. All appears to be well. I don't see any errors.

Did you find this page helpful?