import random
class PrimaryReplicaRouter:
"""Route reads to replicas, writes to primary."""
from django.db.models import Prefetch
from django.views.generic import ListView
from .models import Post, Comment
class PostListView(ListView):
from django.db import models
from django.utils.text import slugify
class Article(models.Model):
title = models.CharField(max_length=200)
class CreateCustomerRevenueSummaries < ActiveRecord::Migration[7.0]
def change
create_view :customer_revenue_summaries, materialized: true, version: 1
add_index :customer_revenue_summaries,
:customer_id,
-- Create basic index
CREATE INDEX idx_users_email ON users(email);
-- Unique index (enforces uniqueness)
CREATE UNIQUE INDEX idx_users_username ON users(username);
<?php
use Illuminate\Support\Facades\DB;
public function createOrder(array $items, User $user)
{
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
package feed
import (
"encoding/base64"
"encoding/json"
"time"
from django.db import models
from django.contrib.postgres.indexes import GinIndex
class Post(models.Model):
title = models.CharField(max_length=200, db_index=True)
from alembic import op
import sqlalchemy as sa
revision = "20240612_add_status"
down_revision = "20240515_create_orders"
branch_labels = None
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=200)
sku = models.CharField(max_length=50)
from django.db import models
from django.contrib.postgres.indexes import GinIndex, BTreeIndex
class Order(models.Model):
customer = models.ForeignKey('Customer', on_delete=models.CASCADE)