Drop & Empty
Foundry provides commands to remove database objects (foundry drop) and to truncate the contents of tables or entire schemas (foundry empty), without requiring you to write DDL or DML.
Warning
drop and empty operations are destructive and cannot be undone. Always verify the target before executing, particularly in production environments.
Drop
The foundry drop command removes database objects. Each subcommand targets a specific object type and requires you to explicitly identify the target.
All drop subcommands accept the standard connection options.
foundry drop schema
Drops a schema and all objects it contains.
foundry drop schema --schema <NAME> [connection options]
foundry drop schema --datasource connection.json --schema archive
foundry drop schema \
--datasource PostgreSQL_17.6.json \
--schema staging
foundry drop table
Drops a single table.
foundry drop table --schema <NAME> --table <NAME> [connection options]
foundry drop table \
--datasource connection.json \
--schema dbo --table temp_import
foundry drop table \
--conn "Server=localhost;Database=mydb;User Id=sa;Password=pass" --db SQLServer \
--schema dbo --table old_archive
foundry drop view
Drops a view.
foundry drop view --schema <NAME> --view <NAME> [connection options]
foundry drop view \
--datasource connection.json \
--schema dbo --view vw_active_customers
foundry drop view \
--datasource PostgreSQL_17.6.json \
--schema public --view vw_monthly_summary
foundry drop index
Drops a named index from a table.
foundry drop index --schema <NAME> --table <NAME> --index <NAME> [connection options]
foundry drop index \
--datasource connection.json \
--schema dbo --table orders --index IX_orders_customer_id
foundry drop index \
--conn "Host=localhost;Database=mydb;Username=postgres;Password=pass" --db PostgreSQL \
--schema public --table products --index IX_products_sku
foundry drop full-text-index
Drops the full-text index from a table.
foundry drop full-text-index --schema <NAME> --table <NAME> [connection options]
foundry drop full-text-index \
--datasource connection.json \
--schema dbo --table articles
foundry drop full-text-index \
--datasource MySql_8.4.json \
--schema blog --table posts
foundry drop spatial-index
Drops the spatial index from a table.
foundry drop spatial-index --schema <NAME> --table <NAME> [connection options]
foundry drop spatial-index \
--datasource PostgreSQL_17.6.json \
--schema public --table locations
foundry drop spatial-index \
--datasource connection.json \
--schema dbo --table sites
Empty
The foundry empty command removes all rows from a table or all tables in a schema without dropping the objects themselves. The schema structure, indexes, and constraints remain intact.
foundry empty schema
Removes all rows from every table in a schema.
foundry empty schema --schema <NAME> [options]
| Option | Short | Description |
|---|---|---|
--schema <NAME> |
-s |
Name of the schema to empty |
--ignore-failures |
Continue if truncating an individual table fails |
foundry empty schema --datasource connection.json --schema dbo
# Continue past tables that fail (e.g. due to FK constraints)
foundry empty schema \
--datasource connection.json \
--schema dbo --ignore-failures
Note
Some databases cannot truncate tables that are referenced by foreign key constraints. Use --ignore-failures to skip these and empty the remaining tables. Remove foreign keys first if you need to empty all tables.
foundry empty table
Removes all rows from a single table.
foundry empty table --schema <NAME> --table <NAME> [connection options]
foundry empty table \
--datasource connection.json \
--schema public --table staging_data
foundry empty table \
--conn "Server=localhost;Database=mydb;User Id=sa;Password=pass" --db SQLServer \
--schema dbo --table audit_log