is there a way to get rid of airbyte inserted 2-4 ...
# ask-ai
s
is there a way to get rid of airbyte inserted 2-4 columns after mysql to postgres migration?
k
Airbyte automatically adds technical columns (such as those prefixed with
_airbyte_
) to destination tables during syncs. These columns are used internally by Airbyte to manage synchronization, track metadata, and support features like deduplication and change data capture. According to official documentation and support responses, there is no built-in way to prevent Airbyte from adding these columns or to hide them during the sync process—they are required for Airbyte's operation and cannot be omitted or suppressed at the destination level during a MySQL to Postgres migration or any other sync type [Hide _airbyte columns created during sync](https://discuss.airbyte.io/t/2868) [Schema map](https://docs.airbyte.com/integrations/destinations/postgres#schema-map). If you need tables without these columns (for example, for end-user consumption), a common workaround is to create views or copy the data into new tables that exclude the Airbyte columns. This approach is also suggested by Airbyte support for destinations like Snowflake, and it applies similarly to Postgres: - Create a view that selects only the columns you want users to see. - Copy data into a new table, omitting the Airbyte columns, if you need a physical table without them. However, you cannot configure Airbyte to stop adding these columns during the sync itself [Hide _airbyte columns created during sync](https://discuss.airbyte.io/t/2868) [Schema map](https://docs.airbyte.com/integrations/destinations/postgres#schema-map).
s
@kapa.ai if I am copying 40+ tables as part of this mysql to postgres migration, give me stored proc/script which can create this view by ignoring any extra airbyte columns added due to migration
k
A message from kapa.ai
There is no ready-made stored procedure or script in the knowledge sources that automatically creates views for all tables while excluding Airbyte-added columns. However, Airbyte support and documentation recommend creating views to hide these technical columns after migration [Destination Snowflake: Dropping technical columns in Snowflake](https://discuss.airbyte.io/t/2468) [Schema map](https://docs.airbyte.com/integrations/destinations/postgres#schema-map). You would need to script this process yourself. A typical approach is to query the information schema to get the list of columns for each table, filter out columns starting with
_airbyte
, and then generate and execute the corresponding
CREATE VIEW
statements. Below is a sample script in PostgreSQL that demonstrates this approach. Note: This is a template and should be reviewed and adapted to your environment. The script generates the SQL for each view, but you will need to execute the generated SQL statements.
Copy code
sql DO $$ DECLARE     tbl RECORD;     col RECORD;     view_sql TEXT; BEGIN     FOR tbl IN         SELECT table_schema, table_name         FROM information_schema.tables         WHERE table_schema = 'public' -- change as needed           AND table_type = 'BASE TABLE'           AND table_name NOT LIKE 'pg_%'           AND table_name NOT LIKE 'sql_%'     LOOP         view_sql := 'CREATE OR REPLACE VIEW ' || tbl.table_schema || '.v_' || tbl.table_name || ' AS SELECT ';         -- Get columns that do NOT start with '_airbyte'         FOR col IN             SELECT column_name             FROM information_schema.columns             WHERE table_schema = tbl.table_schema               AND table_name = tbl.table_name               AND column_name NOT LIKE '\_airbyte%' ESCAPE '\'         LOOP             view_sql := view_sql || col.column_name || ', ';         END LOOP;         -- Remove trailing comma and space         view_sql := left(view_sql, length(view_sql) - 2);         view_sql := view_sql || ' FROM ' || tbl.table_schema || '.' || tbl.table_name || ';';         RAISE NOTICE '%', view_sql; -- This prints the SQL. You can EXECUTE view_sql; to run it.     END LOOP; END $$;
How to use: - This script will print out the
CREATE VIEW
statements for all tables in the
public
schema, prefixing each view with
v_
. - Review the output and run the statements to create the views. Caution: Always review generated SQL before executing, especially in production environments. This approach is in line with Airbyte's recommendations for handling technical columns post-sync [Destination Snowflake: Dropping technical columns in Snowflake](https://discuss.airbyte.io/t/2468). There is no built-in Airbyte feature to automate this, so scripting is the recommended path.