You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-12Lines changed: 67 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,29 @@
1
1
# python-bigquery-migrations
2
2
3
-
Python bigquery-migrations package is for creating and manipulating BigQuery databases easily.
3
+
The `python-bigquery-migrations` package provides a streamlined way to create and manage BigQuery databases using intuitive CLI commands, such as the following:
4
+
5
+
```bash
6
+
bigquery-migrations run
7
+
```
8
+
9
+
**What are the benefits of using migrations?**
4
10
5
11
Migrations are like version control for your database, allowing you to define and share the application's datasets and table schema definitions.
6
12
7
-
## Prerequisite
13
+
## Getting Started
14
+
15
+
## 0. Prerequisite
8
16
9
17
- Google Cloud Project with enabled billing
10
18
- Enabled Google Cloud BigQuery API
11
19
- Google Cloud Service Account JSON file
12
20
13
-
## Getting Started
14
-
15
-
## Install
21
+
## 1. Install
16
22
```
17
23
pip install bigquery-migrations
18
24
```
19
25
20
-
## Create the project folder structure
26
+
## 2. Create the project folder structure
21
27
22
28
Create two subdirectory:
23
29
1. credentials
@@ -30,10 +36,45 @@ your-project-root-folder
30
36
└── ...
31
37
```
32
38
33
-
## Create the neccessary files in the folders
39
+
## 3. Create the neccessary files in the folders
40
+
41
+
### Google Cloud Service Account JSON file
34
42
35
43
Put your Google Cloud Service Account JSON file in the credentials subdirectory. See more info in the [Authorize BigQuery Client section](#authorize-bigquery-client)
36
44
45
+
```
46
+
your-project
47
+
├── credentials
48
+
│ ├── gcp-sa.json
49
+
├── migrations
50
+
└── ...
51
+
```
52
+
53
+
You can use different folder name and file name but in that case you must specify them with command arguments, such as the following:
54
+
55
+
```bash
56
+
bigquery-migrations run --gcp-sa-json-dir my-creds --gcp-sa-json-fname my-service-account.json
|--gcp-sa-json-dir |Name of the service account JSON file directory (optional) |
62
+
|--gcp-sa-json-fname |Name of the service account JSON file (optional) |
63
+
64
+
> **IMPORTANT!**
65
+
> Never check the Google Cloud Service Account JSON file into version control. This file contains sensitive credentials that could compromise your Google Cloud account if exposed.
66
+
67
+
To prevent accidental commits, make sure to add the file to your .gitignore configuration. For example:
68
+
69
+
```bash
70
+
# .gitignore
71
+
gcp-sa.json
72
+
```
73
+
74
+
By ignoring this file, you reduce the risk of unintentional leaks and maintain secure practices in your repository.
75
+
76
+
### Migrations
77
+
37
78
Create your own migrations and put them in the migrations directory. See the [Migration structure section](#migration-structure) and [Migration naming conventions section](#migration-naming-conventions) for more info.
38
79
39
80
```
@@ -45,12 +86,14 @@ your-project
45
86
└── ...
46
87
```
47
88
48
-
You can use different folder names but in that case you must specify them with command arguments:
89
+
You can use different folder name but in that case you must specify it with a command argument:
90
+
91
+
```bash
92
+
bigquery-migrations run --migrations-dir bq-migrations
To reverse all of your migrations, execute the `reset` command:
107
162
108
163
```bash
109
164
bigquery-migrations reset
110
165
```
111
166
112
-
###Authorize BigQuery Client
167
+
## Authorize BigQuery Client
113
168
114
169
Put your service account JSON file in the credentials subdirectory in the root of your project.
115
170
@@ -120,7 +175,7 @@ your-project
120
175
...
121
176
```
122
177
123
-
####Creating a Service Account for Google BigQuery
178
+
### Creating a Service Account for Google BigQuery
124
179
125
180
You can connect to BigQuery with a user account or a service account. A service account is a special kind of account designed to be used by applications or compute workloads, rather than a person. Service accounts don’t have passwords and use a unique email address for identification.
0 commit comments