safetrustcr / Backend

Supports a decentralized platform for secure and trusted P2P cryptocurrency transactions.
3 stars 13 forks source link

Create apartment image table #23

Closed diegoTech14 closed 6 hours ago

diegoTech14 commented 4 days ago

[Backend] Create apartment_images table

Create table to store the apartment images

Problem

Currently, our platform lacks a dedicated table for storing apartment images, which is crucial for:

Solution

Design and implement a new apartment_images table to store and manage apartment-related images systematically.

Migration Files

Create new migration:

hasura migrate create create_apartment_images_table

up.sql:

-- Create apartment_images table
CREATE TABLE apartment_images (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    apartment_id UUID NOT NULL REFERENCES apartments(id) ON DELETE CASCADE,
    image_url TEXT NOT NULL,
    uploaded_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);

-- Create indexes
CREATE INDEX idx_apartment_images_apartment_id ON apartment_images(apartment_id);

down.sql:

DROP TABLE IF EXISTS apartment_images;

Status Flow Diagram

stateDiagram-v2
    [*] --> Created: Image Uploaded
    Created --> Validated: System Check
    Validated --> Active: Approved
    Active --> Deleted: Remove Image
    Deleted --> [*]

Verification Steps

  1. Apply migration:
    hasura migrate apply
  2. Test status flow:
    
    -- Create apartment image
    INSERT INTO apartment_images (
    id,
    apartment_id,
    image_url,
    uploaded_at
    ) VALUES (
    'image-uuid',
    'apartment-uuid',
    'image-url',
    NOW()
    );

-- Select an image SELECT * FROM apartment_images WHERE apartment_id = 'apartment-uuid';

-- Update the image UPDATE apartment_images SET image_url = 'image-url-updated' WHERE id = 'image-uuid';



## Prerequisites
- [ ] Existing `apartments` table
- [ ] Permissions system configured

## Success Criteria
- [ ] Migration runs successfully
- [ ] Table created with correct schema
- [ ] Proper relationships with `apartments` table
- [ ] Permissions correctly implemented

## Additional Context
This implementation:
- [ ] Uses UUID for robust, unique identification
- [ ] Supports multiple images per apartment
- [ ] Captures additional image metadata
- [ ] Implements cascading deletion
- [ ] Includes necessary indexing for performance
GideonBature commented 4 days ago

Can this issue be assigned to me please?

My name is Gideon Bature, a Software Engineer with experience building backend systems using Rust. If given this issue, I should be able to send my first PR within 48 hrs.

Thank you!

Benjtalkshow commented 4 days ago

I'd like to handle this task. I am a Full Stack Developer with a strong background in blockchain and extensive experience in Next.js/React, TypeScript, and Rust. I’ve made over 45 contributions to over 15 projects in the OnlyDust ecosystem, solving complex issues and delivering efficient, scalable solutions.

MY ETA is 48hrs. Thanks

abdegenius commented 4 days ago

I’m interested in this one. Would love to tackle this! I can comfortably handle this issues

Michaelkingsdev commented 4 days ago

Can I take care of this issue?

Ekene001 commented 4 days ago

I'm Ekene, a frontend and blockchain developer, and I’m new to the OnlyDust platform. This is my first time contributing to this repository, and I’m excited about the opportunity to collaborate and bring my skills to the table. Looking forward to making a positive impact and working with the team!

To Tackle this Issue, I will begin by designing and implementing a schema that efficiently manages image data while ensuring integration with the existing apartments table. The primary goal is to enhance the platform’s functionality by providing visual representation of rental properties, supporting landlords in showcasing their apartments, and enabling tenants to make informed decisions based on detailed property visuals. This addition will also improve user trust and overall platform transparency.

I will create a migration file to set up the apartment_images table. The schema will include fields such as id (a unique identifier using UUID), apartment_id (to establish a foreign key relationship with the apartments table), image_url (to store image links), and uploaded_at (to track upload timestamps). I will ensure the foreign key relationship includes cascading deletion, so when an apartment is removed, its associated images are also deleted. For performance, I will implement indexing on the apartment_id field to optimize queries involving apartment-specific images.

After the migration is applied, I will verify the functionality by running tests that include inserting new image records, retrieving images based on apartment IDs, and updating or deleting records to ensure the table behaves as expected. These tests will confirm proper integration with the apartments table, adherence to the schema, and smooth interaction with existing permissions systems.

EmmanuelAR commented 4 days ago

I’d love to work on this task. i will create the table and review the flow, also will work with Diego so will be nice to learn hasura

rvalenciano commented 4 days ago

Hi @EmmanuelAR , please feel free to work on this and ping me if you have questions :)

EmmanuelAR commented 4 days ago

Let's goooo, I will let u know!