Skip to content

webdeveloperkanai/sql-to-firebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEV SEC IT

The DEV SEC IT is a comprehensive toolkit designed to simplify the process of migrating data from a MySQL database to Firestore. It provides a user-friendly interface for selecting and migrating individual tables, ensuring a seamless transition from one database to another. The migration tool is designed to migrate data from a MySQL database to Firestore. It provides a simple web interface for selecting tables and migrating them to Firestore.

MySQL to Firestore Migration Tool

This tool allows you to migrate data from a MySQL database to Firestore one table at a time. It provides a simple web interface to select tables and migrate them individually.

Features

  • User authentication through login form
  • Secure session-based credential storage
  • Tests database and Firestore connections
  • Lists all tables in the database
  • Allows selection of individual tables for migration
  • Migrates selected table data to Firestore in document format
  • Responsive and modern UI with external CSS styling
  • AJAX operations without page reloads
  • Toast notifications for status updates

Setup Instructions

  1. Server Requirements

    • PHP 5.6 or higher
    • MySQL database access
    • Internet connection for Firestore communication
    • cURL extension enabled in PHP
  2. Installation

    • Place all files on a PHP-enabled web server
    • Ensure the server supports sessions
    • Access login.php through your web browser

Usage

  1. Login

    • Access login.php in your web browser
    • Enter your MySQL credentials:
      • Host (e.g., localhost)
      • Username
      • Password
      • Database name
    • Enter your Firestore credentials:
      • Firestore Project ID
      • Firestore Service Account JSON
    • Click "Connect and Continue"
  2. Verify Connections

    • Click the "Test MySQL & Firestore Connections" button to verify your configurations
  3. Load Tables

    • Click the "Load Database Tables" button to fetch all tables from your database
  4. Select and Migrate

    • Choose a table from the list
    • Click "Sync" button next to any table to migrate it to Firestore
  5. Logout

    • Click the "Logout" button to end your session
    • All credentials are cleared from the session

How It Works

  1. The tool accepts your database credentials through a secure login form
  2. Credentials are stored in PHP sessions only for the duration of your visit
  3. When you select a table, it fetches all data from that table
  4. The data is converted to Firestore document format
  5. The documents are sent to your Firestore database using the Firestore REST API
  6. Each MySQL table becomes a Firestore collection with documents for each row

Firestore Authentication

To use this tool:

  1. Go to Firebase Console → Project Settings → Service accounts
  2. Click "Generate new private key"
  3. Download the JSON file
  4. Copy the entire JSON content and paste it in the login form
  5. Enter your Firestore Project ID (found in Project Settings → General)

Firestore Data Structure

After migration, your Firestore database will have the following structure:

collections:
  table_name_1:
    document_1:
      column1: "value1"
      column2: "value2"
    document_2:
      column1: "value3"
      column2: "value4"
  table_name_2:
    // ... documents from second table

Each MySQL table becomes a Firestore collection, and each row becomes a document in that collection.

Security Implementation

This tool implements several security measures for public hosting:

  1. Session-Based Storage: Credentials are stored in PHP sessions, not on the server
  2. HTTP-Only Cookies: Session cookies are protected against XSS attacks
  3. Secure Cookies: Cookies are marked as secure when using HTTPS
  4. Strict Session Mode: Prevents session fixation attacks
  5. No Persistent Storage: No credentials are saved to files or databases

Firestore Setup Requirements

For the tool to work properly with your Firestore project:

  1. Enable Firestore:

    • Go to Firebase Console
    • Click "Firestore Database" in the left sidebar
    • Create a database if you haven't already
  2. Service Account Permissions:

    • The service account should have permissions to read/write to Firestore
    • Default service accounts usually have the necessary permissions
  3. Verify Your Project ID:

    • Make sure you're using the correct Project ID
    • It can be found in Project Settings → General

Troubleshooting

Connection Test Fails:

  • Verify your MySQL credentials are correct
  • Check that your MySQL server is running and accessible
  • Confirm your Firestore Service Account JSON is valid
  • Ensure your Project ID is correct

Sync Fails with Authentication Error:

  • Verify your Firestore Service Account JSON is valid
  • Ensure your Firestore project has the Firestore API enabled
  • Check that your service account has the necessary permissions

Sync Fails with 404 Error:

  • Verify your Project ID is correct
  • Check that Firestore is enabled in your Firebase project
  • Make sure the Google Cloud Firestore API is enabled

Tables Not Loading:

  • Make sure your MySQL credentials are correct
  • Check that the database contains tables
  • Verify that the MySQL user has permissions to access the database

File Structure

The project consists of the following files:

  • login.php - User authentication and credential entry
  • index.php - Main application interface
  • config.php - Application configuration and security settings
  • style.css - Styling for the application interface
  • README.md - This documentation file
  • init.php - Initialization script (optional)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published