Loads initial data into PaperTiger stores on startup.
Configuration
Configure initial data in your application config:
# From a JSON file
config :paper_tiger,
init_data: "/path/to/stripe_init_data.json"
# Or inline as a map
config :paper_tiger,
init_data: %{
products: [
%{
id: "prod_test_standard",
name: "Standard Plan",
active: true,
metadata: %{credits: "100"}
}
],
prices: [
%{
id: "price_test_standard_monthly",
product: "prod_test_standard",
unit_amount: 4900,
currency: "usd",
recurring: %{interval: "month", interval_count: 1}
}
]
}Initial data is loaded after PaperTiger's ETS stores are initialized, making the data available immediately when your application starts. Since ETS is ephemeral, this runs on every application start.
Custom IDs
Use custom IDs to ensure deterministic, reproducible data across application restarts. IDs must match Stripe's format:
- Products:
prod_* - Prices:
price_* - Customers:
cus_* - etc.
Summary
Functions
Loads initial data from configuration.
Loads initial data from a JSON file.
Loads initial data from a map.
Functions
Loads initial data from configuration.
Called automatically during PaperTiger application startup if init_data
is configured. Can also be called manually to reload data.
Returns {:ok, stats} with counts of loaded entities, or {:error, reason}.
Loads initial data from a JSON file.
Paths starting with priv/ are automatically resolved by searching all
loaded applications' priv directories. This allows configurations like
init_data: "priv/paper_tiger/init_data.json" to work both in development
(relative to project root) and in releases (where the file is in the host
application's priv directory).
Loads initial data from a map.
Expected Format
%{
"products" => [...] or products: [...],
"prices" => [...] or prices: [...],
"customers" => [...] or customers: [...]
}