CI Active Record Query not updating - php

I Am trying to update tenders table in my db but for some reasons its updating the table with zeros.
After getting the last_query() string and running it from phpmyadmin window it updates successfully but using active records it does not.
Other queries are working properly apart from this.
What might be the problem with my code?
Here is my code
$data=array(
'tender_type_type_id' => $this->input->post('tender_type_id'),
'Description' => $this->input->post('tdescription'),
'obtaining_documents' => $this->input->post('obtaining_docs'),
'submission_process' => $this->input->post('submission_proc'),
'obtaining_documents' => $this->input->post('obtaining_docs'),
'applicationfee' => $this->input->post('applicationfee'),
'Location' => $this->input->post('location'),
'WebLink' => $this->input->post('url'),
'clossing_date' => $this->input->post('endson'),
'opening_date' => $this->input->post('openedon'),
'title' => $this->input->post('title'),
'publication_date' => date('Y-m-d H:i:s', time()),
'attachments' => $this->input->post('upload'),
'Organization_OrganizationID' => $this->input->post('organizationid'),
'tender_category_category_id' => $this->input->post('categoryid'),
'Towns_TownID' => $this->input->post('townid'),
'Accounts_AccountID' =>$this->input->post('accountid'),
'tender_status_status_id' => $this->input->post('tender_status_id'),
'Location' => $this->input->post('location'),
'clossing_date' => $this->input->post('endson'),
'opening_date' => $this->input->post('openedon'));
$id=$this->uri->segment(3);
$this->db->where('TenderID',$id);
$this->db->update('tenders',$data);
return print_r($this->db->last_query());

Related

Symfony2.8 -> 3.3 Sonata\CoreBundle\Form\Extension\DependencyInjectionExtension::__construct() must be of the type array, object given, called in

I have updated symfony 2.8 -> 3.3
Now Top page looks working.
However when I load the page where uses form builder I burped into this error.
Type error: Argument 3 passed to
Sonata\CoreBundle\Form\Extension\DependencyInjectionExtension::__construct()
must be of the type array, object given, called in
/Users/whitebear/CodingWorks/httproot/myapp/var/cache/dev/appDevDebugProjectContainer.php
on line 1325
I think this is related to service container though, I can’t figure out where should I fix.
What I am doing is like this below
$em = $this->getDoctrine()->getManager();
$reqDoc = new reqDoc();
$form = $this->createFormBuilder($reqDoc)
error messages is below
DependencyInjectionExtension->__construct(object(appDevDebugProjectContainer), array('Symfony\Component\Form\Extension\Core\Type\FormType'
=>object(RewindableGenerator), 'Symfony\Component\Form\Extension\Core\Type\RepeatedType'
=> object(RewindableGenerator), 'Symfony\Component\Form\Extension\Core\Type\SubmitType'
=> object(RewindableGenerator), 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
=> object(RewindableGenerator)), object(RewindableGenerator), null,array('sonata_type_admin'
=> 'Sonata\AdminBundle\Form\Type\AdminType', 'sonata_type_model' => 'Sonata\AdminBundle\Form\Type\ModelType', 'sonata_type_model_list' =>
'Sonata\AdminBundle\Form\Type\ModelTypeList',
'sonata_type_model_reference' =>
'Sonata\AdminBundle\Form\Type\ModelReferenceType',
'sonata_type_model_hidden' =>
'Sonata\AdminBundle\Form\Type\ModelHiddenType',
'sonata_type_model_autocomplete' =>
'Sonata\AdminBundle\Form\Type\ModelAutocompleteType',
'sonata_type_native_collection' =>
'Sonata\AdminBundle\Form\Type\CollectionType',
'sonata_type_choice_field_mask' =>
'Sonata\AdminBundle\Form\Type\ChoiceFieldMaskType',
'sonata_type_filter_number' =>
'Sonata\AdminBundle\Form\Type\Filter\NumberType',
'sonata_type_filter_choice' =>
'Sonata\AdminBundle\Form\Type\Filter\ChoiceType',
'sonata_type_filter_default' =>
'Sonata\AdminBundle\Form\Type\Filter\DefaultType',
'sonata_type_filter_date' =>
'Sonata\AdminBundle\Form\Type\Filter\DateType',
'sonata_type_filter_date_range' =>
'Sonata\AdminBundle\Form\Type\Filter\DateRangeType',
'sonata_type_filter_datetime' =>
'Sonata\AdminBundle\Form\Type\Filter\DateTimeType',
'sonata_type_filter_datetime_range' =>
'Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType', 'tab' =>
'Mopa\Bundle\BootstrapBundle\Form\Type\TabType',
'sonata_block_service_choice' =>
'Sonata\BlockBundle\Form\Type\ServiceListType',
'sonata_type_container_template_choice' =>
'Sonata\BlockBundle\Form\Type\ContainerTemplateType', 'form' =>
'Symfony\Component\Form\Extension\Core\Type\FormType',
'birthday' =>
'Symfony\Component\Form\Extension\Core\Type\BirthdayType',
'checkbox' =>
'Symfony\Component\Form\Extension\Core\Type\CheckboxType',
'choice' =>
'Symfony\Component\Form\Extension\Core\Type\ChoiceType',
'collection' =>
'Symfony\Component\Form\Extension\Core\Type\CollectionType',
'country' =>
'Symfony\Component\Form\Extension\Core\Type\CountryType', 'date'
=> 'Symfony\Component\Form\Extension\Core\Type\DateType', 'datetime' =>
'Symfony\Component\Form\Extension\Core\Type\DateTimeType',
'email' =>
'Symfony\Component\Form\Extension\Core\Type\EmailType', 'file'
=> 'Symfony\Component\Form\Extension\Core\Type\FileType', 'hidden' =>
'Symfony\Component\Form\Extension\Core\Type\HiddenType',
'integer' =>
'Symfony\Component\Form\Extension\Core\Type\IntegerType',
'language' =>
'Symfony\Component\Form\Extension\Core\Type\LanguageType',
'locale' =>
'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'money'
=> 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 'number' =>
'Symfony\Component\Form\Extension\Core\Type\NumberType',
'password' =>
'Symfony\Component\Form\Extension\Core\Type\PasswordType',
'percent' =>
'Symfony\Component\Form\Extension\Core\Type\PercentType',
'radio' =>
'Symfony\Component\Form\Extension\Core\Type\RadioType',
'repeated' =>
'Symfony\Component\Form\Extension\Core\Type\RepeatedType',
'search' =>
'Symfony\Component\Form\Extension\Core\Type\SearchType',
'textarea' =>
'Symfony\Component\Form\Extension\Core\Type\TextareaType',
'text' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
'time' => 'Symfony\Component\Form\Extension\Core\Type\TimeType',
'timezone' =>
'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'url'
=> 'Symfony\Component\Form\Extension\Core\Type\UrlType', 'button' =>
'Symfony\Component\Form\Extension\Core\Type\ButtonType',
'submit' =>
'Symfony\Component\Form\Extension\Core\Type\SubmitType', 'reset'
=> 'Symfony\Component\Form\Extension\Core\Type\ResetType', 'currency' =>
'Symfony\Component\Form\Extension\Core\Type\CurrencyType',
'entity' => 'Symfony\Bridge\Doctrine\Form\Type\EntityType',
'sonata_type_immutable_array' =>
'Sonata\CoreBundle\Form\Type\ImmutableArrayType',
'sonata_type_boolean' =>
'Sonata\CoreBundle\Form\Type\BooleanType',
'sonata_type_collection' =>
'Sonata\CoreBundle\Form\Type\CollectionType',
'sonata_type_translatable_choice' =>
'Sonata\CoreBundle\Form\Type\TranslatableChoiceType',
'sonata_type_date_range' =>
'Sonata\CoreBundle\Form\Type\DateRangeType',
'sonata_type_datetime_range' =>
'Sonata\CoreBundle\Form\Type\DateTimeRangeType',
'sonata_type_date_picker' =>
'Sonata\CoreBundle\Form\Type\DatePickerType',
'sonata_type_datetime_picker' =>
'Sonata\CoreBundle\Form\Type\DateTimePickerType',
'sonata_type_date_range_picker' =>
'Sonata\CoreBundle\Form\Type\DateRangePickerType',
'sonata_type_datetime_range_picker' =>
'Sonata\CoreBundle\Form\Type\DateTimeRangePickerType',
'sonata_type_equal' => 'Sonata\CoreBundle\Form\Type\EqualType',
'sonata_type_color_selector' =>
'Sonata\CoreBundle\Form\Type\ColorSelectorType'), array('form'
=>array('sonata.admin.form.extension.field', 'mopa_bootstrap.form.type_extension.help',
'mopa_bootstrap.form.type_extension.legend',
'mopa_bootstrap.form.type_extension.error',
'mopa_bootstrap.form.type_extension.widget',
'mopa_bootstrap.form.type_extension.horizontal',
'mopa_bootstrap.form.type_extension.widget_collection',
'mopa_bootstrap.form.type_extension.tabbed',
'form.type_extension.form.http_foundation',
'form.type_extension.form.validator', 'form.type_extension.csrf',
'form.type_extension.form.data_collector'), 'choice'
=>array('sonata.admin.form.extension.choice'), 'button' => array('mopa_bootstrap.form.type_extension.button'), 'date' =>array('mopa_bootstrap.form.type_extension.date'), 'repeated' => array('form.type_extension.repeated.validator'), 'submit' =>array('form.type_extension.submit.validator')), array())
in var/cache/dev/appDevDebugProjectContainer.php (line 1325)
Here my answer mentioned in the comments:
Probably you have to upgrade your SonataCoreBundle dependency version as well. Maybe this one is not compatible with Symfony 3.3.

Having a hard time retrieving the customer_id getId() from createCustomer object to pass to createCustomerCard

Here is my code which is the example I used from here
$createcustomer_api = new \SquareConnect\Api\CustomersApi();
$createcustomer_result = $createcustomer_api->createCustomer(array(
'given_name' => 'Amelia',
'family_name' => 'Earhart',
'email_address' => 'Amelia.Earhart#example.com',
'address' => array(
'address_line_1' => '500 Electric Ave',
'address_line_2' => 'Suite 600',
'locality' => 'New York',
'administrative_district_level_1' => 'NY',
'postal_code' => '10003',
'country' => 'US'
),
'phone_number' => '1-555-555-0122',
'reference_id' => 'YOUR_REFERENCE_ID',
'note' => 'a customer'
));
If I print out the results I get
SquareConnect\Model\CreateCustomerResponse Object
(
[errors:protected] =>
[customer:protected] => SquareConnect\Model\Customer Object
(
[id:protected] => CBASEHtp6YVU8AirkMv1lrVMyoIgAQ
[created_at:protected] => 2017-09-27T23:19:44.62Z
[updated_at:protected] => 2017-09-27T23:19:44.62Z
[cards:protected] =>
[given_name:protected] => Amelia
[family_name:protected] => Earhart
[nickname:protected] =>
[company_name:protected] =>
[email_address:protected] => Amelia.Earhart#example.com
[address:protected] => SquareConnect\Model\Address Object
(
[address_line_1:protected] => 500 Electric Ave
[address_line_2:protected] => Suite 600
[address_line_3:protected] =>
[locality:protected] => New York
[sublocality:protected] =>
[sublocality_2:protected] =>
[sublocality_3:protected] =>
[administrative_district_level_1:protected] => NY
[administrative_district_level_2:protected] =>
[administrative_district_level_3:protected] =>
[postal_code:protected] => 10003
[country:protected] => US
[first_name:protected] =>
[last_name:protected] =>
[organization:protected] =>
)
[phone_number:protected] => 1-555-555-0122
[reference_id:protected] => YOUR_REFERENCE_ID
[note:protected] => a customer
[preferences:protected] => SquareConnect\Model\CustomerPreferences Object
(
[email_unsubscribed:protected] =>
)
[groups:protected] =>
)
)
Now I need to create the customer card to associate with the customer for future recurring payments.
$createcard_api = new \SquareConnect\Api\CustomersApi();
$createcard_result = $createcard_api->createCustomerCard($createcustomer_result->getId(), array(
'card_nonce' => $nonce,
'billing_address' => array(
'address_line_1' => '1455 Market St',
'address_line_2' => 'Suite 600',
'locality' => 'San Francisco',
'administrative_district_level_1' => 'CA',
'postal_code' => '94103',
'country' => 'US'
),
'cardholder_name' => 'Amelia Earhart'
));
From what I understand there is a built-in function with the square SDK that is getId() which according to this is called like $customer->getId(), but according to this I need to just add ->getId() to my createCustomer object.
So I am trying to call the getId() function as
$createcustomer_result->getId()
but in my code I am getting the error
Fatal error: Call to undefined method SquareConnect\Model\CreateCustomerResponse::getId()
How do I properly get the customer id from the createCustomer?
You've only got the response object from the API, a communication device. You need to first extract the created object from the response, then you can query it for the ID.
$customer = $createcustomer_result->getCustomer();
That should get you the actual customer object, then you can:
$customer_id = $customer->getId();
This is pretty common for API libraries. You can also query the response object for errors if they occur. When using these kinds of libraries, have a look inside the various classes and read through the functions, you can get a better idea of how you use them that way.

for each loop PHP Facebook

I try to make a web application for my thesis.
Actually it is almost finished but I still have to find a way to store the likes of users in a database. I collect user information and try to see if there is a relation between movies that he or she like and user data elements that are saved in different SNSs. For single information it already save the things the way it should be. The problem is, that facebook work with arrays and objects and I am not able to find a way to save all the likes in a single string (and then save it in a database).
// Insert or update user data to the database
$fbUserData = array(
'oauth_provider' => 'facebook',
//basic profile
'oauth_uid' => $fbUserProfile['id'],
'first_name' => $fbUserProfile['first_name'],
'last_name' => $fbUserProfile['last_name'],
'picture' => $fbUserProfile['picture']['url'],
'email' => $fbUserProfile['email'],
'link' => $fbUserProfile['link'],
'age_range' => $fbUserProfile['age_range']['min'],
'currency' => $fbUserProfile['currency']['user_currency'],
'devices' => $fbUserProfile['devices'],//['hardware']
'gender' => $fbUserProfile['gender'],
'install_type' => $fbUserProfile['install_type'],
'installed' => $fbUserProfile['installed'],
'is_shared_login' => $fbUserProfile['is_shared_login'],
'is_verified' => $fbUserProfile['is_verified'],
'locale' => $fbUserProfile['locale'],
'name_format' => $fbUserProfile['name_format'],
'payment_pricepoints' => $fbUserProfile['payment_pricepoints'], //credits?
'security_settings' => $fbUserProfile['security_settings']['secure_browsing']['enabled'],
'test_group' => $fbUserProfile['test_group'],
'timezone' => $fbUserProfile['timezone'],
'updated_time' => $fbUserProfile['updated_time'],
'verified' => $fbUserProfile['verified'],
'video_upload_limits' => $fbUserProfile['video_upload_limits']['size'],
'viewer_can_send_gift' => $fbUserProfile['viewer_can_send_gift'],
//extended permissions
'relationship_status' => $fbUserProfile['relationship_status'],
'hometown' => $fbUserProfile['hometown']['name'],
'languages' => $fbUserProfile['languages'][0]['name'].",".$fbUserProfile['languages'][1]['name'].",".$fbUserProfile['languages'][2]['name'].",".$fbUserProfile['languages'][3]['name'].",".$fbUserProfile['languages'][4]['name'],
//'likes' => $fbUserProfile['likes'][0]['name'].",".$fbUserProfile['likes'][1]['name']
'favorite_athletes' => $fbUserProfile['favorite_athletes'][0]['name'].",".$fbUserProfile['favorite_athletes'][1]['name'].",".$fbUserProfile['favorite_athletes'][2]['name'].",".$fbUserProfile['favorite_athletes'][3]['name'].",".$fbUserProfile['favorite_athletes'][4]['name'].",".$fbUserProfile['favorite_athletes'][5]['name'].",".$fbUserProfile['favorite_athletes'][6]['name'],
);
$userData = $user->checkUser($fbUserData);
//print
echo $userData['languages'];
echo $userData['favorite_athletes'];
As you can see for languages, likes, favorite_athletes I coded it in the ugly way now to read the profile and store it. The problem is that some people have over 100 likes, and it is of course not handy to code it in this way. When I use the
for each it always bug...
If you're just interested in concatenating arrays for a single table then use PHPs implode function http://php.net/manual/en/function.implode.php
combined with an array map as mentioned here
How to use implode on an array of stdClass objects?
alternatively normalise your database as mentioned in a comment
'favorite_athletes' => implode(",", array_map(function($x) { return $x['name'];},$fbUserProfile['favorite_athletes']));
'likes' => implode(",", array_map(function($x){ return $x['name']}, $fbUserProfile['likes']['data']));
// Insert or update user data to the database
$fbUserData = array(
'oauth_provider' => 'facebook',
//basic profile
'oauth_uid' => $fbUserProfile['id'],
'first_name' => $fbUserProfile['first_name'],
'last_name' => $fbUserProfile['last_name'],
'picture' => $fbUserProfile['picture']['url'],
'email' => $fbUserProfile['email'],
'link' => $fbUserProfile['link'],
'age_range' => $fbUserProfile['age_range']['min'],
'currency' => $fbUserProfile['currency']['user_currency'],
'devices' => $fbUserProfile['devices'][0]['hardware'],
'gender' => $fbUserProfile['gender'],
'install_type' => $fbUserProfile['install_type'],
'installed' => $fbUserProfile['installed'],
'is_shared_login' => $fbUserProfile['is_shared_login'],
'is_verified' => $fbUserProfile['is_verified'],
'locale' => $fbUserProfile['locale'],
'name_format' => $fbUserProfile['name_format'],
'payment_pricepoints' => $fbUserProfile['payment_pricepoints'], //credits?
'security_settings' => $fbUserProfile['security_settings']['secure_browsing']['enabled'],
'test_group' => $fbUserProfile['test_group'],
'timezone' => $fbUserProfile['timezone'],
'updated_time' => $fbUserProfile['updated_time'],
'verified' => $fbUserProfile['verified'],
'video_upload_limits' => $fbUserProfile['video_upload_limits']['size'],
'viewer_can_send_gift' => $fbUserProfile['viewer_can_send_gift'],
//extended permissions
'relationship_status' => $fbUserProfile['relationship_status'],
'hometown' => $fbUserProfile['hometown']['name'],
'languages' => implode(",", array_map(function($x) { return $x['name'];},$fbUserProfile['languages'])),//$fbUserProfile['languages'][0]['name'].",".$fbUserProfile['languages'][1]['name'].",".$fbUserProfile['languages'][2]['name'].",".$fbUserProfile['languages'][3]['name'].",".$fbUserProfile['languages'][4]['name'],
'likes' => implode(",", array_map(function($x){ return $x['name'];}, $fbUserProfile['likes']['data'])),
'favorite_athletes' => implode(",", array_map(function($x) { return $x['name'];},$fbUserProfile['favorite_athletes']))

SugarCRM On-Demand Convert TextField to DropDown

A similar question was posted here before but it only applied to an On-Site SugarCRM instance (it was also a long time ago).
In my case I would like to change the "Billing Country" field from 'TextField' to 'DropDdown' on an On-Demand instance where I don't have access to the config files. How can I do this?
So far I have tried different PHP files using the Module Loader but it's not working either.
Please find my PHP script below:
<?php
$manifest = array(
'acceptable_sugar_flavors' => array('CE', 'PRO', 'CORP', 'ENT', 'ULT'),
'acceptable_sugar_versions' => array(
'exact_matches' => array(),
'regex_matches' => array(
0 => '6\\.5\\.(.*?)',
1 => '6\\.7\\.(.*?)',
2 => '7\\.2\\.(.*?)',
3 => '7\\.2\\.(.*?)\\.(.*?)',
4 => '7\\.5\\.(.*?)\\.(.*?)',
5 => '7\\.6\\.(.*?)\\.(.*?)'
),
),
'name' => 'Textfield to Dropdown',
'description' => 'Converting Billing Country textfield to Dropdown Field',
'author' => 'myname',
'icon' => '',
'is_uninstallable' => true,
'published_date' => '2015-01-09 19:00:00',
'type' => 'module',
'version' => '1.0',
);
$dictionary['Account']['fields']['billing_address_country']['type'] = 'enum';
$dictionary['Account']['fields']['billing_address_country']['ext1'] = 'countries_dom';
The module loads fine but there's no change after a Quick Repair. I have tried with the following variables, as well:
$dictionary['Account']['fields']['billing_address_country']['isDropDown']=yes;
and...
$dictionary['Account']['fields']['billing_address_country']['Options']='countries_dom';
Can anyone tell me what I am doing wrong? I'd appreciate any help or guidance you have. Please advise.
Cheers,
H
P.S. I am using SugarCRM On-Demand Version 7.6.1
You need to create the manifest.php file and have that point to the file(s) you want to copy/upload for customization:
manifest.php:
<?php
$manifest = array(
'built_in_version' => '7.6.1.0',
'acceptable_sugar_versions' =>
array(
0 => '',
),
'acceptable_sugar_flavors' =>
array(
0 => 'PRO',
1 => 'CORP',
2 => 'ENT',
3 => 'ULT',
),
'readme' => '',
'key' => 'SO',
'author' => 'Eric',
'description' => 'Convert Accounts Billing Country TextField to Enum',
'icon' => '',
'is_uninstallable' => true,
'name' => 'TextFieldToDropdownPkg',
'published_date' => '2016-01-10 03:01:01',
'type' => 'module',
'version' => 1452378413,
'remove_tables' => 'prompt',
);
$installdefs = array(
'id' => 'TextFieldToDropdownPkg',
'copy' => array(
0 => array(
'from' => '<basepath>/custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php',
'to' => 'custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php',
),
),
);
Then create:
custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php
<?php
$dictionary['Account']['fields']['billing_address_country']['comments']='Country for primary address';
$dictionary['Account']['fields']['billing_address_country']['group']='primary_address';
$dictionary['Account']['fields']['billing_address_country']['options']='countries_dom';
$dictionary['Account']['fields']['billing_address_country']['type']='enum';
ZIP those files up and use Module Loader.

Laravel 5.1 entering multiple duplicate records into the database

I have written an application using Laravel 5.1. The application is for parking spaces. It "provisions" the spaces by creating 3 different available slots in the database (Morning, Afternoon, All Day).
The problem is that on a quick page refresh, the spaces are provisioned twice, resulting in 6 slots getting entered into the database.
However, if I refresh the page after a 5 second delay, no further records are entered. My if statement below seems to work, just not when the page / connection is refreshed quickly.
foreach($bays as $bay) {
if(!BookingDates::where('date', $date)->where('parking_bay', $bay->number)->count()) {
BookingDates::insert(['parking_bay' => $bay->number, 'date' => $date, 'slot' => 'Morning', 'time' => '7am - 1pm', 'status' => 'Available', 'created_at' => DB::raw('now()')]);
BookingDates::insert(['parking_bay' => $bay->number, 'date' => $date, 'slot' => 'Afternoon', 'time' => '1pm - 7pm', 'status' => 'Available', 'created_at' => DB::raw('now()')]);
BookingDates::insert(['parking_bay' => $bay->number, 'date' => $date, 'slot' => 'All Day', 'time' => null, 'status' => 'Available', 'created_at' => DB::raw('now()')]);
}
}
Does anyone know why this might happen?
When dealing with this sort of issue, database transactions often turn out to be part of the solution. The code will look something like this:
DB::transaction(function () use ($bays, $date){
foreach($bays as $bay) {
if(!BookingDates::where('date', $date)->where('parking_bay', $bay->number)->count()) {
BookingDates::insert(['parking_bay' => $bay->number, 'date' => $date, 'slot' => 'Morning', 'time' => '7am - 1pm', 'status' => 'Available', 'created_at' => DB::raw('now()')]);
BookingDates::insert(['parking_bay' => $bay->number, 'date' => $date, 'slot' => 'Afternoon', 'time' => '1pm - 7pm', 'status' => 'Available', 'created_at' => DB::raw('now()')]);
BookingDates::insert(['parking_bay' => $bay->number, 'date' => $date, 'slot' => 'All Day', 'time' => null, 'status' => 'Available', 'created_at' => DB::raw('now()')]);
}
}
});
To really ensure data integrity, you'll also want to define a unique index across the columns parking_bay, date, and slot. You may need to step outside the migration API and just execute a SQL statement in your migration, which will vary based on whether you are using MySQL, MSSQL, Postgres, etc.
Between transactions and a unique index, the database will refuse to insert duplicate rows and will rollback the bad insert, so you won't be stuck with something like one person having the morning slot and another having the all day slot.
Let me know if you need any further help!

Categories