This will create/update your Appwrite database structure. Make sure you:
- Have a backup of your current database
- Are deploying to the correct project
- Have reviewed the schema thoroughly
- Understand the changes being made
- Backup current database (if any)
- Review
appwrite.config.json - Read
DATABASE_SCHEMA.md - Verify Appwrite CLI is installed
- Confirm project ID is correct
- Check API endpoint is correct
- Have necessary permissions
npm install -g appwrite-cliappwrite loginFollow the prompts to authenticate.
Check that your appwrite.config.json has the correct:
projectId: "tenchat"endpoint: "https://fra.cloud.appwrite.io/v1"
Deploy everything at once:
# Deploy all resources
appwrite deploy
# Or deploy specific resources
appwrite deploy database
appwrite deploy collection
appwrite deploy bucketDeploy step by step:
appwrite deploy databaseThis creates the 5 databases:
- MainDatabase
- SocialDatabase
- Web3Database
- ContentDatabase
- AnalyticsDatabase
appwrite deploy collectionThis creates all 30 collections with their attributes and indexes.
Expected time: 5-10 minutes
appwrite deploy bucketThis creates 12 storage buckets for different media types.
If CLI fails, you can manually create via the Appwrite Console:
- Go to your Appwrite Console
- Create each database manually
- Create collections with attributes
- Add indexes
- Create storage buckets
Solution: The CLI will update existing databases. If you want fresh:
# Delete old databases via console first, then redeploy
appwrite deploy database --forceSolution: The CLI should handle this, but if it fails:
- Delete the collection via console
- Redeploy that specific collection
Solution: Ensure you have admin/owner access to the project:
appwrite login
# Re-authenticate with correct credentialsSolution: Deploy in smaller batches:
# Deploy one database at a time
appwrite deploy collection --collection profiles
appwrite deploy collection --collection conversations
# etc...appwrite databases listExpected output:
β mainDB - MainDatabase
β socialDB - SocialDatabase
β web3DB - Web3Database
β contentDB - ContentDatabase
β analyticsDB - AnalyticsDatabase
appwrite collections list --databaseId mainDBShould show: profiles, conversations, messages, etc.
appwrite buckets listShould show 12 buckets.
Try creating a test document:
# Create test profile
appwrite documents create \
--databaseId mainDB \
--collectionId profiles \
--documentId unique() \
--data '{"userId":"test123","username":"testuser"}'- MainDatabase - Core messaging
- SocialDatabase - Social features
- Web3Database - Blockchain integration
- ContentDatabase - Rich media
- AnalyticsDatabase - Metrics & logs
- profiles
- conversations
- messages
- messageQueue
- contacts
- typingIndicators
- presence
- stories
- storyViews
- posts
- postReactions
- comments
- follows
- wallets
- nfts
- cryptoTransactions
- tokenGifts
- contractHooks
- tokenHoldings
- stickers
- stickerPacks
- userStickers
- gifs
- polls
- arFilters
- mediaLibrary
- userActivity
- notifications
- appAnalytics
- errorLogs
- avatars (10MB)
- covers (20MB)
- messages (100MB)
- stories (50MB)
- posts (100MB)
- nfts (50MB)
- stickers (5MB)
- filters (20MB)
- gifs (10MB)
- voice (50MB)
- video (500MB)
- documents (100MB)
- Edit
generate-schema.cjs - Run
node generate-schema.cjs - Review changes in
appwrite.config.json - Deploy updates:
appwrite deploy collection --force# 1. Test locally first
node generate-schema.cjs
# 2. Review changes
git diff appwrite.config.json
# 3. Backup production
# Export data via Appwrite Console
# 4. Deploy to staging first
appwrite deploy --project staging-project-id
# 5. Test thoroughly
# 6. Deploy to production
appwrite deploy --project tenchat- Stop immediately - Don't make more changes
- Document the issue - Note what failed
- Restore from backup if available
- Contact support if data is corrupted
# Backup specific collection
appwrite documents list \
--databaseId mainDB \
--collectionId profiles \
--limit 1000 > backup-profiles.json
# Restore (manual process via console)Check Appwrite logs for slow queries and add indexes as needed.
If hitting limits:
- Split large JSON fields into separate collections
- Use storage for large text content
- Implement pagination
Enable compression on buckets:
- Already enabled for all buckets (gzip)
- Monitor storage usage via console
Create .env file:
VITE_APPWRITE_PROJECT_ID=tenchat
VITE_APPWRITE_ENDPOINT=https://fra.cloud.appwrite.io/v1
VITE_APPWRITE_DATABASE_MAIN=mainDB
VITE_APPWRITE_DATABASE_SOCIAL=socialDB
VITE_APPWRITE_DATABASE_WEB3=web3DB
VITE_APPWRITE_DATABASE_CONTENT=contentDB
VITE_APPWRITE_DATABASE_ANALYTICS=analyticsDB# Production
appwrite deploy --project tenchat
# Staging
appwrite deploy --project tenchat-staging
# Development
appwrite deploy --project tenchat-devIf you have existing data:
// migration-script.js
const sdk = require('node-appwrite');
async function migrate() {
const client = new sdk.Client();
const databases = new sdk.Databases(client);
client
.setEndpoint('https://fra.cloud.appwrite.io/v1')
.setProject('tenchat')
.setKey('your-api-key');
// Migrate old messages to new schema
const oldMessages = await databases.listDocuments(
'oldDB',
'oldMessages'
);
for (const msg of oldMessages.documents) {
await databases.createDocument(
'mainDB',
'messages',
sdk.ID.unique(),
{
conversationId: msg.chatId,
senderId: msg.sender,
content: msg.text,
contentType: 'text',
createdAt: msg.timestamp
}
);
}
}
migrate().catch(console.error);After deployment, verify:
β All 5 databases created β All 30 collections exist with correct attributes β Indexes are created and active β All 12 storage buckets configured β Permissions are set correctly β Can create/read test documents β Can upload test files to storage β No errors in Appwrite logs
- Check Appwrite logs in console
- Review this deployment guide
- Check DATABASE_SCHEMA.md for collection details
- Post in Appwrite Discord with:
- Error message
- Steps to reproduce
- Schema section causing issues
-
Update Frontend Code
- Import database IDs
- Update API calls
- Test all features
-
Set Up Real-time Subscriptions
- Subscribe to message updates
- Listen for typing indicators
- Track online presence
-
Implement Features
- User authentication
- Message sending/receiving
- Story creation
- Crypto wallet connection
-
Monitor Performance
- Set up alerts
- Track API usage
- Monitor storage
-
Launch & Scale
- Gradual rollout
- Monitor metrics
- Scale databases as needed
# Final checklist
node generate-schema.cjs # Ensure schema is up to date
appwrite login # Authenticate
appwrite deploy # Deploy everything!Good luck! You're building the next big thing! π