Generate Code That Will Seed Data Into A Database

Generate code that will seed data into a database

A
aiscribe
·May 3, 2026·
49 0 24
$7.99
Prompt
453 words

You are a professional developer. Your task is to generate {codebase_summary} that seeds DB with records according to the provided YAML specification. If an entity with a specific Id was already listed in the YAML, then do not create the entity, update the existing one instead. However, all listed entities must first be created. This code will be used as data seeding code for a unit test. Generation of a unit test is out of scope here.

Example source class name: MyClassABC Example testing scenario: Recording URL must be set when Zoom call is logged Example dataset in YAML format:

- object_api_name: User
  id: user1
  data:
    - Name: TestUser
- object_api_name: Opportunity
  id: opp1
  data:
    - Type: Renewal
    - StageName: Pending
    - CloseDate: ⟨today⟩
    - Renewal_Date__c: ⟨today + 1 month⟩
    - OwnerId: $⟨user1⟩
- object_api_name: Contact
  id: contact1
  data:
    - Name: Test Contact
- object_api_name: Task
  data:
    - WhoId: ⟨contact1⟩
    - WhatId: ⟨opp1⟩
    - OwnerId: ⟨user1⟩
    - Subject: Renewal Call - DNN
    - Type: Call
    - CallDisposition: Complete - Action needed
    - Proof_Of_Work_URL__c: https://zoom.com/?meeting_id=testId123

Example APEX output:

@isTest
public class MyClassABCTests ⟨
    public static void Data_ShouldSetRecrodingUrlWhenZoomCallLogged() {{
        // Generate a random alphanumeric string for the username
        String randomString = String.valueOf(Math.abs(Crypto.getRandomInteger())).substring(0,3);
        // Format today's date
        String todayDate = Date.today().format('YYYYMMdd');
        // Construct the username and email using the generated parts
        String usernameEmail = 'test' + randomString + todayDate + '@example.com';
        // Create a new User
        User testUser = new User(
            Username = usernameEmail,
            LastName = 'User',
            FirstName = 'Test',
            Alias = 'tuser', // Ensure Alias is unique and within required length
            Email = usernameEmail,
            ProfileId = [SELECT Id FROM Profile WHERE Name = 'Standard User'].Id,
            TimeZoneSidKey = 'America/Los_Angeles',
            LocaleSidKey = 'en_US',
            EmailEncodingKey = 'UTF-8',
            LanguageLocaleKey = 'en_US'
        );
        insert testUser; // Insert the user into the database
        // Create a new Contact
        Contact contact1 = new Contact(Name = 'Test Contact');
        insert contact1; // Insert the contact into the database
        // Calculate dates for the Opportunity
        Date today = Date.today();
        Date nextMonth = today.addMonths(1);
        // Create a new Opportunity
        Opportunity opp1 = new Opportunity(
            Name = 'Opportunity for ' + contact1.Name,
            Type = 'Renewal',
            StageName = 'Pending',
            CloseDate = today,
            Renewal_Date__c = nextMonth,
            OwnerId = testUser.Id
        );
        insert opp1; // Insert the opportunity into the database
        // Create a new Task related to the Contact and Opportunity
        Task task1 = new Task(
            WhoId = contact1.Id,
            WhatId = opp1.Id,
            OwnerId = testUser.Id,
            Subject = 'Renewal Call - DNN',
            Type = 'Call',
            CallDisposition = 'Complete - Action needed',
            Proof_Of_Work_URL__c = 'https://zoom.com/?meeting_id=testId123'
        );
        insert task1; // Insert the task into the database
    ⟩
}}

Here are the details:

  • Tested class name: {codebase_class_name}
  • Tested scenario: {gherkin_test}

Here is the dataset in YAML format: {test_dataset}

This prompt contains variables shown as ⟨variable_name⟩. Replace them with your own values before using.

How to Use

Use with LangChain: hub.pull("hub1/aitesting_seed_data")

Need help?

Connect with verified experts who can help you succeed.

Related Prompts

More prompts in Coding & Development

View All
Coding & Development
Universal

This Prompt Ads Sequential Function Calling To Models Other Than GPT 0613

This prompt ads sequential function calling to models other than GPT-0613

D
digitalmuse$2.99
39,910 89,588
Coding & Development
Universal

Create a personalized workout routine

Tailor a workout routine specifically designed for individual fitness goals

P
primequery$2.99
23,370 23,405
Coding & Development
Universal

GODMODE CHEATCODE

God Writes You a Letter Today. This is will help you find the perfect Bible Scripture that will guide you through a current problem you're facing.

S
signalcraft$3.99
13,574 13,622
Coding & Development
Universal

Creating a Personal Finance Tracker with [Technology/Tool]

Learn to create a personal finance tracker using [Technology/Tool]. Get code samples and budgeting tips.

F
focusqueryFree
376 385
Coding & Development
ChatGPT

Build an entire application using bubble.io with ChatGPT4

Build an entire app with bubble.io, assisted by chatGPT4, that knows bubble very well and is accurate 95% of the time. This prompt will help you maximize the quality of chatGPT assistance. Having detailed and step-by-step instructions is essential to progress fast with Bubble. This initial prompt will help you get started on a good basis. Follow it because I will make it even better.

P
promptframes$5.99
1,280 1,300
Coding & Development
Universal

Become LawyerGPT

Are you in a legal bind? This prompt can help you gain knowledge about how to handle your legal proceedings. DISCLAIMER: Please meet with a real lawyer to discuss your options.

P
promptbench$2.99
1,063 1,076