denny/ShinyCMS

View on GitHub
bin/database/data/insert-poll-demo-data

Summary

Maintainability
Test Coverage
#!/usr/bin/env perl

# ===================================================================
# File:        bin/database/insert-poll-demo-data
# Project:    ShinyCMS
# Purpose:    Insert poll demo data via DBIC
# 
# Author:    Denny de la Haye <2019@denny.me>
# Copyright (c) 2009-2019 Denny de la Haye
# 
# ShinyCMS is free software; you can redistribute it and/or modify it
# under the terms of either the GPL 2.0 or the Artistic License 2.0
# ===================================================================

use strict;
use warnings;

# Load local helper lib and get connected schema object
use FindBin qw( $Bin );
use lib "$Bin/../../lib";
require 'helpers.pl';  ## no critic

my $schema = get_schema();


# Create a poll question
my $poll = $schema->resultset( 'PollQuestion' )->find_or_create({
    question => 'Poll goes where?',
});

# Add some answers to the poll
$poll->poll_answers->find_or_create({
    answer => 'Here',
});
$poll->poll_answers->find_or_create({
    answer => 'There',
});
$poll->poll_answers->find_or_create({
    answer => 'Everywhere',
});