cockroachdb / cockroachdb/cockroach
Rename a table with backward compatibility
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Is your feature request related to a problem? Please describe.**
Hello. In PostgreSQL I have a killer feature that I can rename a table with backward compatibility by creating a view which acts as a proxy table.
Step 1. Create a view
```
create view NEW_TABLE_NAME as (select * from OLD_TABLE);
```
Step 2. Migrate my service to use NEW_TABLE_NAME.
- This will work as in PostgreSQL you can use DML with views, and they will proxy all calls to the table.
Step 3. Rename a table and drop the view
```
begin;
rename view NEW_TABLE_NAME to TABLE_NAME_TO_DELETE;
rename table OLD_TABLE to NEW_TABLE_NAME;
drop view TABLE_NAME_TO_DELETE;
commit;
```
Is there any safe way to rename a table in cockroachDB as well?
Jira issue: CRDB-24916
Epic CRDB-28834
Contributor guide
Assessment
This issue has not been assessed yet.