backend for xcvr appview

use environment variables, correct migrations

+4 -4
docker-compose.yml
··· 3 3 image: postgres:15 4 4 restart: unless-stopped 5 5 environment: 6 - POSTGRES_USER: xcvr 7 - POSTGRES_PASSWORD: secret 8 - POSTGRES_DB: xcvrdb 6 + POSTGRES_USER: ${POSTGRES_USER} 7 + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} 8 + POSTGRES_DB: ${POSTGRES_DB} 9 9 ports: 10 - - "15432:5432" 10 + - "${POSTGRES_PORT}:5432" 11 11 volumes: 12 12 - dbdata:/var/lib/posgresql/data 13 13
+3 -1
migratedown
··· 1 1 #!/bin/bash 2 - migrate -path migrations -database "postgres://xcvr:secret@localhost:15432/xcvrdb?sslmode=disable" down 2 + source .env 3 + 4 + migrate -path migrations -database "postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:$POSTGRES_PORT/$POSTGRES_DB?sslmode=disable" down
+3 -1
migrateup
··· 1 1 #!/bin/bash 2 - migrate -path migrations -database "postgres://xcvr:secret@localhost:15432/xcvrdb?sslmode=disable" up 2 + source .env 3 + 4 + migrate -path migrations -database "postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:$POSTGRES_PORT/$POSTGRES_DB?sslmode=disable" up
migrations/002_init.down.sql migrations/001_init.down.sql
+5
migrations/002_populate.down.sql
··· 1 + DELETE FROM messages; 2 + DELETE FROM signets; 3 + DELETE FROM channels; 4 + DELETE FROM did_handle; 5 + DELETE FROM profiles;
+24
migrations/002_populate.up.sql
··· 1 + INSERT INTO profiles (did, display_name, default_nick, status, avatar_cid, avatar_mime, color, uri, cid) 2 + VALUES 3 + ('did:example:alice', 'Alice Example', 'alice', 'Chilling', 'bafybeib6...', 'image/png', 16711680, 'at://did:example:alice/app.bsky.actor.profile/self', 'cid1'), 4 + ('did:example:bob', 'Bob Example', 'bobby', 'Working hard', 'bafybeib7...', 'image/jpeg', 65280, 'at://did:example:bob/app.bsky.actor.profile/self', 'cid2'); 5 + 6 + INSERT INTO did_handle (handle, did) 7 + VALUES 8 + ('alice.com', 'did:example:alice'), 9 + ('bob.net', 'did:example:bob'); 10 + 11 + INSERT INTO channels (uri, cid, did, host, title, topic, created_at) 12 + VALUES 13 + ('at://did:example:alice/org.xcvr.channel/general', 'chanCid1', 'did:example:alice', 'alice.com', 'General Chat', 'All-purpose chatter', now() - interval '2 days'), 14 + ('at://did:example:bob/org.xcvr.channel/help', 'chanCid2', 'did:example:bob', 'bob.net', 'Help Channel', 'Support and help', now() - interval '1 day'); 15 + 16 + INSERT INTO signets (uri, did, channel_uri, message_id, cid) 17 + VALUES 18 + ('at://did:example:alice/org.xcvr.lrc/signet1', 'did:example:alice', 'at://did:example:alice/org.xcvr.channel/general', 1, 'signetCid1'), 19 + ('at://did:example:bob/org.xcvr.lrc/signet2', 'did:example:bob', 'at://did:example:bob/org.xcvr.channel/help', 2, 'signetCid2'); 20 + 21 + INSERT INTO messages (uri, did, signet_uri, body, nick, color, cid) 22 + VALUES 23 + ('at://did:example:alice/org.xcvr.lrc.message/msg1', 'did:example:alice', 'at://did:example:alice/org.xcvr.lrc/signet1', 'Hey, welcome to the general chat!', 'alice', 16711680, 'msgCid1'), 24 + ('at://did:example:bob/org.xcvr.lrc.message/msg2', 'did:example:bob', 'at://did:example:bob/org.xcvr.lrc/signet2', 'How can I help you today?', 'bobby', 65280, 'msgCid2');
+3 -1
psql
··· 1 1 #!/bin/bash 2 - docker exec -it xcvr-backend-db-1 psql -U xcvr -d xcvrdb 2 + source .env 3 + 4 + docker exec -it xcvr-backend-db-1 psql -U $POSTGRES_USER -d $POSTGRES_DB