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

sql: tool/command to convert a set of databases into a single database under a schema #50885

Closed
rohany opened this issue Jul 1, 2020 · 0 comments · Fixed by #52997
Closed
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@rohany
Copy link
Contributor

rohany commented Jul 1, 2020

This is open to discussion on how/if we want to do this. Many customers are currently using databases as schemas to separate their table within their organization. We are moving towards not supporting cross database references, and would like those use cases to be replaced with a single database and a set of schemas. We should provide some way of automating this transformation.

@rohany rohany added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Jul 1, 2020
rohany added a commit to rohany/cockroach that referenced this issue Aug 18, 2020
Fixes cockroachdb#50885.

This commit introduces a command to convert a database into a user
defined schema under a desired database. This command can be used by
users who are currently emulating a Postgres style set of schemas in
CockroachDB with separate databases.

Release note: TODO (rohany): Fill this out once it stabilizes.
rohany added a commit to rohany/cockroach that referenced this issue Aug 19, 2020
Fixes cockroachdb#50885.

This commit introduces a command to convert a database into a user
defined schema under a desired database. This command can be used by
users who are currently emulating a Postgres style set of schemas in
CockroachDB with separate databases.

Release note (sql change): Users can now convert existing databases into
schemas under other databases through the
`ALTER DATABASE ... CONVERT TO SCHEMA UNDER PARENT ...` command. This
command can only be run by `admin` and is only valid for databases that
don't already have any child schemas other than `public`.
rohany added a commit to rohany/cockroach that referenced this issue Aug 20, 2020
Fixes cockroachdb#50885.

This commit introduces a command to convert a database into a user
defined schema under a desired database. This command can be used by
users who are currently emulating a Postgres style set of schemas in
CockroachDB with separate databases.

Release note (sql change): Users can now convert existing databases into
schemas under other databases through the
`ALTER DATABASE ... CONVERT TO SCHEMA UNDER PARENT ...` command. This
command can only be run by `admin` and is only valid for databases that
don't already have any child schemas other than `public`.
rohany added a commit to rohany/cockroach that referenced this issue Aug 20, 2020
Fixes cockroachdb#50885.

This commit introduces a command to convert a database into a user
defined schema under a desired database. This command can be used by
users who are currently emulating a Postgres style set of schemas in
CockroachDB with separate databases.

Release note (sql change): Users can now convert existing databases into
schemas under other databases through the
`ALTER DATABASE ... CONVERT TO SCHEMA UNDER PARENT ...` command. This
command can only be run by `admin` and is only valid for databases that
don't already have any child schemas other than `public`.
craig bot pushed a commit that referenced this issue Aug 20, 2020
52997: sql: introduce a command to convert a database into a schema r=rohany a=rohany

Fixes #50885.

This commit introduces a command to convert a database into a user
defined schema under a desired database. This command can be used by
users who are currently emulating a Postgres style set of schemas in
CockroachDB with separate databases.

Release note (sql change): Users can now convert existing databases into
schemas under other databases through the
`ALTER DATABASE ... CONVERT TO SCHEMA UNDER PARENT ...` command. This
command can only be run by `admin` and is only valid for databases that
don't already have any child schemas other than `public`.

53078: stats: use leased types in the stats cache r=rohany a=rohany

This commit switches the stats cache to use leased types rather than
accessing types directly. This was the final user of the direct type
access methods, so that code is removed as well.

Release note: None

53137: sql: fix panic when resolving a target on non-existent db r=pbardea a=pbardea

When trying to resolve a target on non-existent DB, we would have a nil
deference panic due to a missing error check.

Some ways that could have triggered this panic:
- Resolving {types,sequences}
- Renaming a table

Release note (bug fix): Fix a crash that may occur when referencing a
database that does not exist when trying to create a type, sequence or
when renaming a table.

Co-authored-by: Rohan Yadav <[email protected]>
Co-authored-by: Paul Bardea <[email protected]>
@craig craig bot closed this as completed in ab3463b Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant