Changing model of live data
At some point we realize that attaching one order per User was a mistake. Possible steps to refactor our model:
- create new component class Order with property "details" of type ScalarTable
- add new User property "orders" of type ComponentCollection of Orders, using script bin/admin/apply-new-component-properties
- programmatically create one Order component per "order_details" and add it to "orders"
- delete obsolete User property "order_details"
#!/usr/bin/perl -w use Podius; use Podius::Shortcuts; my $cache = create_component_cache(); my $center = $cache->get_component("Center", 1) or die "No Center"; $cache->begin_tx; # foreach_user is our Podius::Component::Center method $center->foreach_user(sub { my $user = shift; my $order = $cache->create_component("Order"); $order->details($user->order_details); $user->orders->add($order); }); $cache->commit_tx;