Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fresh install with Postgres failed with "42703: column "settingname" does not exist POSITION: 43" #2032

Closed
ghhv opened this issue Feb 28, 2022 · 7 comments

Comments

@ghhv
Copy link

ghhv commented Feb 28, 2022

Fresh install of Oqtane.Server V3.0.3 via VS2022 on Windows with Postgresql V12 database.
I created a new Postgres database with default template0 and added an admin user with all rights.
Added config to Oqtane setup page and it came back with the error "42703: column "settingname" does not exist POSITION: 43".
A migration has indeed run on Postgres and there are now tables created but as per the error, the "tenant" table is missing a "settings" column.
image
image
image

I note the Tenant model class does not have a "setting" field, yet the "InitializeTenant" migration is trying to create an index with it.

Error.log entry
`[2022-02-28 07:22:30+00:00] [Error] [Oqtane.Infrastructure.DatabaseManager] 42703: column "settingname" does not exist

POSITION: 43 `

thanks.

@ghhv
Copy link
Author

ghhv commented Mar 1, 2022

So, using the default MSLocalDb SQL Server, it worked without issue (for a fresh install) and it doesn't have any settings column in the tenant table.. Actually looking back at the error, I don't know why I thought it's looking for that in the tenant table.. maybe from that Index command in "InitializeTenant".

Also, the broken Postgres install above won't start at all now.. message - "Site Is Either Disabled Or Not Configured Correctly". Will try a fresh Postgres tomorrow.

@ghhv
Copy link
Author

ghhv commented Mar 2, 2022

For anyone else experiencing this, clearing the connection string in appsettings.json will restart the config process.

Unfortunately on a new Postgres database, same error.

@ghhv
Copy link
Author

ghhv commented Mar 2, 2022

So found the problem - was very hard without a stack trace!
this code is updating a column
image

which calls this:
image

Note the WHERE condition field name..

But the database looks like this:
image

The issue is the RewriteName/Value does not get applied to the "condition" clause.

@ghhv
Copy link
Author

ghhv commented Mar 2, 2022

This update is also affected by the same bug

settingEntityBuilder.UpdateColumn("IsPrivate", "1", "bool", "EntityName = 'Site' AND SettingName LIKE 'SMTP%'");

EntityName should also be ReWritten.

@ghhv
Copy link
Author

ghhv commented Mar 3, 2022

Here's working code.. I wasn't sure on what to do with creating a Pull request with the versioning in your migrations.

For some reason the code formatting would not work here so have added gists instead.

https://gist.github.com/ghhv/6a485943a29fd6b9e499946457a951f2

https://gist.github.com/ghhv/1c86871f7a480a1ce324613bb6ca5c4d

@sbwalker
Copy link
Member

sbwalker commented Mar 3, 2022

thank you for tracking this down... multi-database support is definitely a challenge based on the differences between different database platforms. Since nobody has reported this issue previously I am going to assume that PostgreSQL is not being used extensively - so I am inclined to simply apply the fix in the existing migrations. This will allow new installations to work properly - as well as any older installations to upgrade properly as well. Do you want to submit a PR or do you want me to make the change on your behalf?

@ghhv
Copy link
Author

ghhv commented Mar 5, 2022

Hi Shaun, I've never done a PR and I didn't know what to do with that versioning.. so yes, you can do for now.. Maybe as I get into this more, I'll give it a go.

And question - is there a reason why the stack trace is not showing any line number details? I was running as DEBUG.

sbwalker added a commit that referenced this issue Mar 7, 2022
Fix #2032 - Fresh install with Postgres failed with "42703: column "settingname" does not exist POSITION: 43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants