mirror of
https://github.com/gogs/gogs.git
synced 2026-06-23 10:39:33 +02:00
docs: migrate to Mintlify (#8154)
This commit is contained in:
131
docs/dev/database_schema.md
Normal file
131
docs/dev/database_schema.md
Normal file
@@ -0,0 +1,131 @@
|
||||
# Table "access"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
--------+---------+-----------------+-----------------------+-----------------------
|
||||
ID | id | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER AUTOINCREMENT
|
||||
UserID | user_id | BIGINT NOT NULL | BIGINT NOT NULL | INTEGER NOT NULL
|
||||
RepoID | repo_id | BIGINT NOT NULL | BIGINT NOT NULL | INTEGER NOT NULL
|
||||
Mode | mode | BIGINT NOT NULL | BIGINT NOT NULL | INTEGER NOT NULL
|
||||
|
||||
Primary keys: id
|
||||
Indexes:
|
||||
"access_user_repo_unique" UNIQUE (user_id, repo_id)
|
||||
```
|
||||
|
||||
# Table "access_token"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
-------------+--------------+-----------------------------+-----------------------------+-----------------------------
|
||||
ID | id | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER AUTOINCREMENT
|
||||
UserID | uid | BIGINT | BIGINT | INTEGER
|
||||
Name | name | TEXT | LONGTEXT | TEXT
|
||||
Sha1 | sha1 | VARCHAR(40) UNIQUE | VARCHAR(40) UNIQUE | VARCHAR(40) UNIQUE
|
||||
SHA256 | sha256 | VARCHAR(64) NOT NULL UNIQUE | VARCHAR(64) NOT NULL UNIQUE | VARCHAR(64) NOT NULL UNIQUE
|
||||
CreatedUnix | created_unix | BIGINT | BIGINT | INTEGER
|
||||
UpdatedUnix | updated_unix | BIGINT | BIGINT | INTEGER
|
||||
|
||||
Primary keys: id
|
||||
Indexes:
|
||||
"idx_access_token_user_id" (uid)
|
||||
```
|
||||
|
||||
# Table "action"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
--------------+----------------+--------------------------------+--------------------------------+--------------------------------
|
||||
ID | id | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER AUTOINCREMENT
|
||||
UserID | user_id | BIGINT | BIGINT | INTEGER
|
||||
OpType | op_type | BIGINT | BIGINT | INTEGER
|
||||
ActUserID | act_user_id | BIGINT | BIGINT | INTEGER
|
||||
ActUserName | act_user_name | TEXT | LONGTEXT | TEXT
|
||||
RepoID | repo_id | BIGINT | BIGINT | INTEGER
|
||||
RepoUserName | repo_user_name | TEXT | LONGTEXT | TEXT
|
||||
RepoName | repo_name | TEXT | LONGTEXT | TEXT
|
||||
RefName | ref_name | TEXT | LONGTEXT | TEXT
|
||||
IsPrivate | is_private | BOOLEAN NOT NULL DEFAULT FALSE | BOOLEAN NOT NULL DEFAULT FALSE | NUMERIC NOT NULL DEFAULT FALSE
|
||||
Content | content | TEXT | LONGTEXT | TEXT
|
||||
CreatedUnix | created_unix | BIGINT | BIGINT | INTEGER
|
||||
|
||||
Primary keys: id
|
||||
Indexes:
|
||||
"idx_action_repo_id" (repo_id)
|
||||
"idx_action_user_id" (user_id)
|
||||
```
|
||||
|
||||
# Table "email_address"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
-------------+--------------+--------------------------------+--------------------------------+--------------------------------
|
||||
ID | id | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER AUTOINCREMENT
|
||||
UserID | uid | BIGINT NOT NULL | BIGINT NOT NULL | INTEGER NOT NULL
|
||||
Email | email | VARCHAR(254) NOT NULL | VARCHAR(254) NOT NULL | TEXT NOT NULL
|
||||
IsActivated | is_activated | BOOLEAN NOT NULL DEFAULT FALSE | BOOLEAN NOT NULL DEFAULT FALSE | NUMERIC NOT NULL DEFAULT FALSE
|
||||
|
||||
Primary keys: id
|
||||
Indexes:
|
||||
"email_address_user_email_unique" UNIQUE (uid, email)
|
||||
"idx_email_address_user_id" (uid)
|
||||
```
|
||||
|
||||
# Table "follow"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
----------+-----------+-----------------+-----------------------+-----------------------
|
||||
ID | id | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER AUTOINCREMENT
|
||||
UserID | user_id | BIGINT NOT NULL | BIGINT NOT NULL | INTEGER NOT NULL
|
||||
FollowID | follow_id | BIGINT NOT NULL | BIGINT NOT NULL | INTEGER NOT NULL
|
||||
|
||||
Primary keys: id
|
||||
Indexes:
|
||||
"follow_user_follow_unique" UNIQUE (user_id, follow_id)
|
||||
```
|
||||
|
||||
# Table "lfs_object"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
-----------+------------+----------------------+----------------------+-------------------
|
||||
RepoID | repo_id | BIGINT | BIGINT | INTEGER
|
||||
OID | oid | TEXT | VARCHAR(191) | TEXT
|
||||
Size | size | BIGINT NOT NULL | BIGINT NOT NULL | INTEGER NOT NULL
|
||||
Storage | storage | TEXT NOT NULL | LONGTEXT NOT NULL | TEXT NOT NULL
|
||||
CreatedAt | created_at | TIMESTAMPTZ NOT NULL | DATETIME(3) NOT NULL | DATETIME NOT NULL
|
||||
|
||||
Primary keys: repo_id, oid
|
||||
```
|
||||
|
||||
# Table "login_source"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
-------------+--------------+------------------+-----------------------+-----------------------
|
||||
ID | id | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER AUTOINCREMENT
|
||||
Type | type | BIGINT | BIGINT | INTEGER
|
||||
Name | name | TEXT UNIQUE | VARCHAR(191) UNIQUE | TEXT UNIQUE
|
||||
IsActived | is_actived | BOOLEAN NOT NULL | BOOLEAN NOT NULL | NUMERIC NOT NULL
|
||||
IsDefault | is_default | BOOLEAN | BOOLEAN | NUMERIC
|
||||
Config | cfg | TEXT | TEXT | TEXT
|
||||
CreatedUnix | created_unix | BIGINT | BIGINT | INTEGER
|
||||
UpdatedUnix | updated_unix | BIGINT | BIGINT | INTEGER
|
||||
|
||||
Primary keys: id
|
||||
```
|
||||
|
||||
# Table "notice"
|
||||
|
||||
```
|
||||
Field | Column | PostgreSQL | MySQL | SQLite3
|
||||
-------------+--------------+------------+-----------------------+-----------------------
|
||||
ID | id | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER AUTOINCREMENT
|
||||
Type | type | BIGINT | BIGINT | INTEGER
|
||||
Description | description | TEXT | TEXT | TEXT
|
||||
CreatedUnix | created_unix | BIGINT | BIGINT | INTEGER
|
||||
|
||||
Primary keys: id
|
||||
```
|
||||
|
||||
17
docs/dev/import_locale.md
Normal file
17
docs/dev/import_locale.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Import locales from Crowdin
|
||||
|
||||
1. Upload the latest version of [`locale_en-US.ini`](https://github.com/gogs/gogs/blob/main/conf/locale/locale_en-US.ini) to the [Crowdin](https://crowdin.gogs.io/project/gogs/sources/files).
|
||||
1. [Build and download](https://crowdin.gogs.io/project/gogs/translations) the ZIP archive and unzip it.
|
||||
1. Go to root directory of the repository.
|
||||
1. Run the `import` subcommand:
|
||||
|
||||
```
|
||||
$ ./.bin/gogs import locale --source <path to the unzipped directory> --target ./conf/locale
|
||||
Locale files has been successfully imported!
|
||||
```
|
||||
|
||||
1. Run `task web` to start the web server, then visit the site in the browser to make sure nothing blows up.
|
||||
1. Check out a new branch using `git checkout -b update-locales`.
|
||||
1. Stage changes
|
||||
1. Run `git commit -m "locale: sync from Crowdin"`.
|
||||
1. Push the commit then open up a pull request on GitHub.
|
||||
174
docs/dev/local_development.md
Normal file
174
docs/dev/local_development.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# Set up your development environment
|
||||
|
||||
Gogs is written in [Go](https://golang.org/), please take [A Tour of Go](https://tour.golang.org/) if you haven't done so!
|
||||
|
||||
## Outline
|
||||
|
||||
- [Environment](#environment)
|
||||
- [Step 1: Install dependencies](#step-1-install-dependencies)
|
||||
- [Step 2: Initialize your database](#step-2-initialize-your-database)
|
||||
- [Step 3: Get the code](#step-3-get-the-code)
|
||||
- [Step 4: Configure database settings](#step-4-configure-database-settings)
|
||||
- [Step 5: Start the server](#step-5-start-the-server)
|
||||
- [Other nice things](#other-nice-things)
|
||||
|
||||
## Environment
|
||||
|
||||
Gogs is built and runs as a single binary and meant to be cross platform. Therefore, you should be able to develop Gogs in any major platforms you prefer.
|
||||
|
||||
## Step 1: Install dependencies
|
||||
|
||||
Gogs has the following dependencies:
|
||||
|
||||
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) (v1.8.3 or higher)
|
||||
- [Go](https://golang.org/doc/install) (v1.20 or higher)
|
||||
- [Less.js](http://lesscss.org/usage/#command-line-usage-installing)
|
||||
- [Task](https://github.com/go-task/task) (v3)
|
||||
- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports)
|
||||
- [go-mockgen](https://github.com/derision-test/go-mockgen)
|
||||
- Database upon your choice (pick one, we choose PostgreSQL in this document):
|
||||
- [PostgreSQL](https://wiki.postgresql.org/wiki/Detailed_installation_guides) (v9.6 or higher)
|
||||
- [MySQL](https://dev.mysql.com/downloads/mysql/) with `ENGINE=InnoDB` (v5.7 or higher)
|
||||
- [SQLite3](https://www.sqlite.org/index.html)
|
||||
- [TiDB](https://github.com/pingcap/tidb)
|
||||
|
||||
### macOS
|
||||
|
||||
1. Install [Homebrew](https://brew.sh/).
|
||||
1. Install dependencies:
|
||||
|
||||
```bash
|
||||
brew install go postgresql git npm go-task/tap/go-task
|
||||
npm install -g less
|
||||
npm install -g less-plugin-clean-css
|
||||
go install github.com/derision-test/go-mockgen/cmd/go-mockgen@v1.3.3
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
```
|
||||
|
||||
1. Configure PostgreSQL to start automatically:
|
||||
|
||||
```bash
|
||||
brew services start postgresql
|
||||
```
|
||||
|
||||
1. Ensure `psql`, the PostgreSQL command line client, is on your `$PATH`.
|
||||
Homebrew does not put it there by default. Homebrew gives you the command to run to insert `psql` in your path in the "Caveats" section of `brew info postgresql`. Alternatively, you can use the command below. It might need to be adjusted depending on your Homebrew prefix (`/usr/local` below) and shell (bash below).
|
||||
|
||||
```bash
|
||||
hash psql || { echo 'export PATH="/usr/local/opt/postgresql/bin:$PATH"' >> ~/.bash_profile }
|
||||
source ~/.bash_profile
|
||||
```
|
||||
|
||||
### Ubuntu
|
||||
|
||||
1. Add package repositories:
|
||||
|
||||
```bash
|
||||
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
|
||||
```
|
||||
|
||||
1. Update repositories:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
```
|
||||
|
||||
1. Install dependencies:
|
||||
|
||||
```bash
|
||||
sudo apt install -y make git-all postgresql postgresql-contrib golang-go nodejs
|
||||
npm install -g less
|
||||
go install github.com/go-task/task/v3/cmd/task@latest
|
||||
go install github.com/derision-test/go-mockgen/cmd/go-mockgen@v1.3.3
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
```
|
||||
|
||||
1. Configure startup services:
|
||||
|
||||
```bash
|
||||
sudo systemctl enable postgresql
|
||||
```
|
||||
|
||||
## Step 2: Initialize your database
|
||||
|
||||
You need a fresh Postgres database and a database user that has full ownership of that database.
|
||||
|
||||
1. Create a database for the current Unix user:
|
||||
|
||||
```bash
|
||||
# For Linux users, first access the postgres user shell
|
||||
sudo su - postgres
|
||||
```
|
||||
|
||||
```bash
|
||||
createdb
|
||||
```
|
||||
|
||||
2. Create the Gogs user and password:
|
||||
|
||||
```bash
|
||||
createuser --superuser gogs
|
||||
psql -c "ALTER USER gogs WITH PASSWORD '<YOUR PASSWORD HERE>';"
|
||||
```
|
||||
|
||||
3. Create the Gogs database
|
||||
|
||||
```bash
|
||||
createdb --owner=gogs --encoding=UTF8 --template=template0 gogs
|
||||
```
|
||||
|
||||
## Step 3: Get the code
|
||||
|
||||
Generally, you don't need a full clone, so set `--depth` to `10`:
|
||||
|
||||
```bash
|
||||
git clone --depth 10 https://github.com/gogs/gogs.git
|
||||
```
|
||||
|
||||
**NOTE** The repository has Go modules enabled, please clone to somewhere outside of your `$GOPATH`.
|
||||
|
||||
## Step 4: Configure database settings
|
||||
|
||||
Create a `custom/conf/app.ini` file inside the repository and put the following configuration (everything under `custom/` directory is used to override default files and is excluded by `.gitignore`):
|
||||
|
||||
```ini
|
||||
[database]
|
||||
TYPE = postgres
|
||||
HOST = 127.0.0.1:5432
|
||||
NAME = gogs
|
||||
USER = gogs
|
||||
PASSWORD = <YOUR PASSWORD HERE>
|
||||
SSL_MODE = disable
|
||||
```
|
||||
|
||||
## Step 5: Start the server
|
||||
|
||||
The following command will start the web server and automatically recompile and restart the server if any Go files changed:
|
||||
|
||||
```bash
|
||||
task web --watch
|
||||
```
|
||||
|
||||
**NOTE** If you changed any file under `conf/`, `template/` or `public/` directory, be sure to run `task generate` afterwards!
|
||||
|
||||
## Other nice things
|
||||
|
||||
### Load HTML templates and static files from disk
|
||||
|
||||
When you are actively working on HTML templates and static files during development, you may want to enable the following configuration to avoid recompiling and restarting Gogs every time you make a change to files under `template/` and `public/` directories:
|
||||
|
||||
```ini
|
||||
RUN_MODE = dev
|
||||
|
||||
[server]
|
||||
LOAD_ASSETS_FROM_DISK = true
|
||||
```
|
||||
|
||||
### Offline development
|
||||
|
||||
Sometimes you will want to develop Gogs but it just so happens you will be on a plane or a train or perhaps a beach, and you will have no WiFi. And you may raise your fist toward heaven and say something like, "Why, we can put a man on the moon, so why can't we develop high-quality Git hosting without an Internet connection?" But lower your hand back to your keyboard and fret no further, you *can* develop Gogs with no connectivity by setting the following configuration in your `custom/conf/app.ini`:
|
||||
|
||||
```ini
|
||||
[server]
|
||||
OFFLINE_MODE = true
|
||||
```
|
||||
Reference in New Issue
Block a user