basecamp / basecamp/activerecord-tenanted

After creating the tenanted database the tables are not accessible

Open
#344 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
617
Forks
29
PR merge metrics
No merged PRs in 30d

Description

The tables inside the tenanted database table can't be accessed right after the tenanted db has been created despite the fact that they've been created on disk.

My pseudocode is like this:
- register the user (create a new user)
- create a tenanted database: `Project.create_tenant tenant_slug`
- switch to tenant of the current_user
-then do the domain specific work within the newly created tenant

The Error:
- ``` ::Payments::BillingInfo.current_tenant: "14d66e" ```
- ```::Payments::BillingInfo.count
eval error: SQLite3::SQLException: no such table: payments_billing_infos:
SELECT COUNT(*) FROM "payments_billing_infos"```

The error otherwise:
```
CoreRecord.with_tenant('14d66e') do Payments::BillingInfo.count end
eval error: SQLite3::SQLException: no such table: payments_billing_infos:
SELECT COUNT(*) FROM "payments_billing_infos"
```

As You can see on the disk the tenanted directory exists:
Image

Even the database exists:
Image

As I open the dataabse file even the table inside the database exists:
Image

Contributor guide

Open the contributing guide

Research direction

Reproduce the flow using Project.create_tenant, tenant switching, and CoreRecord.with_tenant, then query Payments::BillingInfo.count against the newly created SQLite database. Compare the database file and its tables with the connection used by the query. Done means tables in a freshly created tenant are accessible immediately after creation.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, sqlite
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.