Skip to content

Postgres adapter raises error when using a copy to csv with a read replica (regression) #39166

@Fivell

Description

@Fivell

Steps to reproduce

SlaveDb.connection.execute("COPY (select * from table_name) TO '#{file_path}.csv' WITH CSV HEADER;")

Expected behavior

it is possible to export data from replica database to csv file
COPY TO - readable sql
COPY FROM - writable sql
https://www.postgresql.org/docs/9.2/sql-copy.html

Actual behavior

The following error is raised: ActiveRecord::ReadOnlyError: Write query attempted while in readonly mode ...

System configuration

Rails version:
6.0.2.2
Ruby version:
2.5.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions